Visual Studio not breaking on user-unhandled excep

2019-01-14 20:03发布

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.

9条回答
来,给爷笑一个
2楼-- · 2019-01-14 20:32

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.

查看更多
趁早两清
3楼-- · 2019-01-14 20:33

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.

查看更多
贪生不怕死
4楼-- · 2019-01-14 20:33

Changing target platform from x64 to x86 helped me

查看更多
再贱就再见
5楼-- · 2019-01-14 20:35

The only thing that worked for me was:

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

查看更多
Lonely孤独者°
6楼-- · 2019-01-14 20:36

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.
查看更多
冷血范
7楼-- · 2019-01-14 20:39

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.

查看更多
登录 后发表回答