Why does Visual Studio stop debugging my app? - visual-studio-2010

There's a really weird bug in my app (C#, WPF based UI): in a certain scenario, if I unpin the explorer, I'm getting tons of exceptions (System.NullReferenceException – Object reference not set to an instance of an object).
The problem is: I can't find the specific reason for this exception because Visual Studio stops debugging (so there is no stacktrace, and no evidence for the exception).
I tried changing the exception handling settings in VS to throw any exception instead of handling it, but it didn't help.
How can I find the exact location which threw the exception?

Related

Break when the first exception occurs in Visual Studio 2019

I'm using VS 2019, I'm wondering if there is a way to break when an exception is thrown, even if it is caught.
I can't manage to find out where the exception is really thrown since there are many exception handlers and the exception pop-up comes up when the stack is no longer indicating anything.
Thanks
You have to go into the exception settings of Visual studio (you can easily find it with the search bar)
And then you check the exception category that is needed (CLR for example)
Uncheck it after when it is no more needed (or use the restore default button)

Why does my program always throw an access violation exception in mfc140d.dll?

The program crashes after 30-45 minutes of operation with the following message:
Exception Thrown at 0xFCA6551 (mfc140d.dll) in WinPDM.exe: 0xC0000005: Access Violation reading location 0x00000008.
The exception occurs when running in both debug mode and from a release build in Visual Studio 2017. The program suddenly shows errors in rendering boxes and buttons, and if one then tries to press a button or select an item, the exception occurs.
The program was originally writtin in Visual C++ 6.0 and ported somewhat successfully to Visual Studio 2017. Many errors were found and removed after running the built-in intellisense analyzer in VS2017, but the exception still occurs. It also occurs in the older versions of the program built in Visual C++ 6.0.
I am looking for suggestions on how to pinpoint where this error is coming from and how to address it.
We have already tried to backtrace using the VS2017 debugger, and also attempted to step into the function call where the exception occurs:
size = m_ShiftList.GetDC()->GetTextExtent(str);
but the debugger refuses to step into the function at this point.
The program can pass through this point with no issues for the first 30-45 minutes of operation. Removing this code (since we can live without knowing the size of the text) moved the same exception to occur at a different point.

Exceptions not thrown in web api

I'm using Web Api and when an exception happens in my code (for example a bad cast), and the debugger is attached, the exception is not thrown in Visual Studio. I just get the 500 internal server error on the browser side with the exception details but it's a pain because I have to track down what line it's thrown on.
I don't believe this was always the case, and thought it must be one of my settings messed up but I have already tried to reset visual studio settings to no avail.
How can I get the debugger to break again on 500 internal server errors.. I don't want to enable first chance exceptions.
Tools -> Options -> Debugging -> General, Ensure that "Enable Just My Code" is checked.
In visual studio Debug->Exceptions for exceptions that you need or for all of them select checkbox in the Throw column. It's because by default Asp.Net runtime handles all exceptions. MSDN

A first chance exception of type 'StructureMap.StructureMapException' occurred in StructureMap.DLL

Hello I'm getting this exception thrown at me whenever I try to test a web application via visual studio, any ideas why? I'm building a project using MVC3 model and visual studio 2010
Exception: A first chance exception of type 'StructureMap.StructureMapException' occurred in StructureMap.DLL
First chance exceptions might occur while debugging. They might be handled properly by your code and never propagate when running the application normally but nevertheless Visual Studio shows them in Debug mode. If you don't want to be bothered you could disable them in Visual Studio and they will no longer appear.

Visual Studio Just-In-Time Debugging Annoyances

I have a solution comprising of about 6 projects, and when I debug on one machine, any un-handled exceptions that occur cause the environment to break at the point that exception is thrown, allowing me to debug it.
However, on a different machine with the same solution (in the same version of VS), all I get when an exception is thrown is the "Visual Studio Just-In-Time debugging" window popping up, which tells me the name of the exception, and little else - it offers to open a new visual studio instance in order to debug it, but that doesn't work, because it is already being debugged by the IDE!
What is going on, and how can I get back to visual studio telling me where the exception happened?
Cheers
You might want to check Exceptions in the Debug menu (mapped by default to Ctrl+Alt+E) and verify that both machines have the same exceptions selected.
Probably on the second machine you have less exception types selected in that window. When one of the exceptions that are not selected is thrown:
the debugger does not handle it because it has been instructed not to
the exception gets passes to the OS
the OS launches the default system-wide debugger which is the "Visual Studio Just-In-Time debugging" launcher if you installed VS2005 on that machine.
Sounds like it can't find the debug info.
Try copying the PDB files to your output directory.
I've had this problem as well - two machines, identical exception settings, different behaviours. The solution for me was to set the Debugger Type in the project properties on the "bad" machine to Mixed, even though the application only contains managed code. On the "good" machine exceptions are caught in Visual Studio using the Managed Only setting.

Resources