Visual Studio not breaking on user-unhandled exceptions

蓝咒 提交于 2019-12-17 16:24:55

问题


When running my app in Visual Studio, it's ending on unhandled exceptions rather than showing a message box with the exception info and continuing on as I'm accustomed to.

What options do I need to change to get it back to the behavior I'm used to?

Edit: In Debug/Exceptions I do have the User-unhandled option selected for CLR Exceptions.


回答1:


Debug->Exceptions->Check Thrown/User-Unhandled for Common Language Runtime Exceptions

edit: Maybe try to do a clean/rebuild, and run again? Maybe debug symbols are corrupt or something..




回答2:


For visual studio 2015 :

1.Open Exception settings window (it's new in 2015)

2.Check All CLR Exceptions

3.If you don't need visual studio to throw specific exceptions uncheck this




回答3:


Depending on the application, the following options may help you:

Tools → Options... → Debugging → General

  • Break when exceptions cross AppDomain or managed/native boundaries (Managed only)
  • Enable the exception assistant
    • Unwind the call stack on unhandled exceptions
  • Uncheck Enable Just My Code ← JMC can prevent you from catching exceptions in code that's not yours and/or is missing symbols.



回答4:


In my case, when I went to Debug -> Exceptions, the User-unhandled column was missing. Going to Debug -> Options and Settings and enabling Enable Just My Code fixed this, which consequently fixed this problem altogether.




回答5:


This fixed it for me: in the quick lauch (Ctrl-Q) type "ResetToC#" (or ResetTo something else)

I had the same problem for a long time. In the Debug->Exceptions menu, the "User-unhandled" column was missing! Extremely annoying.

I uninstalled all my plugins, did a reinstall of VS, but nothing worked (Visual Studio probably left some settings on my machine that it reused after reinstalling).

This might not seem like the best solution as there must be some setting somewhere that would have done it as well. I couldn't find it and after not being able to break on user-unhandled exceptions for months, the ResetToC# option was a relief.




回答6:


I was having the same issue in Visual Studio 2013 on a very large C# project. However if I created a new empty project and threw a test ApplicationException, everything would work as expected and the debugger would break and give me the exception assistant. Doing the same on my existing project would just stop debugging and return to VS editing mode. I noticed in the "Output" window, the last debug trace would show

The program '[2624] MyApplication.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

I don't really have the luxury of copying everything into a new project, and none of the suggestions above worked for me. By trial and error I found something that worked: Uncheck the "Unwind the call stack on unhandled exceptions" under Options > Debugging > General > Enable the exception assistant.

By the way, if I manually force the call stack to unwind on this same C# project through the exception assistant (by clicking the "Enable editing" link), the debugger just closes and I can't edit-and-continue. But on a fresh project, it does unwind and edit-and-continue works just fine! So there is a definitely something about my project that VS does not like, but I'll use this as an acceptable workaround for now.




回答7:


The only thing that worked for me was:

Tools -> Import and Export Settings -> Reset all settings and then reset to C#.




回答8:


Changing target platform from x64 to x86 helped me




回答9:


If you have more than one Web Site project in your solution, check that the project you want to debug is active. Right click it and select Set as StartUp Project.

This stumped me for a while since there are no obvious cues that the wrong website is being debugged.



来源:https://stackoverflow.com/questions/16970642/visual-studio-not-breaking-on-user-unhandled-exceptions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!