Microsoft Visual Studio C# 2010 Express:可以调试但不能构建
当我调试我的 C# 程序 F5 时,我的程序将按预期运行;然而,在构建它后CTRL+F5,我的程序立即关闭:“(程序)已停止工作”。对此有哪些可能的解释?
When I debug my C# program F5, my program will run as intended; however, upon building it CTRL+F5, my program immediately shuts down: "(Program) has stopped working". What are some possible explanations for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要试图猜测这一点并编写代码来告诉您。为 AppDomain.Current.UnhandledException 添加事件处理程序并显示 e.ExceptionObject.ToString() 的值。
Don't try to guess at this and write the code to tell you. Add an event handler for AppDomain.Current.UnhandledException and display the value of e.ExceptionObject.ToString().
Ctrl+F5 通常不是构建的快捷方式,而是在不附加调试器的情况下启动程序的快捷方式。
我猜想您的程序会使用不同的工作文件夹启动并崩溃,因为您在某处尝试访问与工作文件夹相关的文件,而当您使用 Ctrl+F5 启动时找不到该文件。
Ctrl+F5 is usually not the shortcut for building, but for starting the program without the debugger attached.
I would guess that your program is then started with a different working folder and crashes because you somewhere try to access a file relative to the working folder that is not found when you start with Ctrl+F5.