Reputation: 1921
In an application I'm making, sometimes exceptions that are thrown but unhandled, seem to disappear into thin air and cause strange bugs with the GUI.
I'll usually find it by stepping through until reaching the line where the exception is thrown, at which point Visual Studio immediately stops stepping and returns to the application.
It's an IRC app so it's heavily event-driven by the async socket connection. Not sure if that is relevant.
I don't have any empty catch blocks anywhere or anything like that.
Upvotes: 1
Views: 809
Reputation: 1921
Apparently this is a known bug with x64 machines.
The bug and a workaround is on Microsoft Connect.
Edit:
If anyone is interested in the cause, this was posted when the bug was closed:
Hello,
This bug was closed as "External" because this behavior results from how x64 version of Windows handle exceptions. When a user mode exception crosses a kernel transition, x64 versions of Windows do not allow the exception to propagate. Therefore attached debuggers are unaware of the fact that an exception occured resulting in the debugger failing to break on the unhandled exception.
Unfortunately where is nothing that the Visual Studo team can do to address this, it is the result of operating system design. All feedback regarding this issue should be addressed to the Windows team; however the Windows team considers this to be the "correct" operating system design, and considers the x86 behavior to be "incorrect".
Best Regards, Visual Studio Debugger
Upvotes: 3
Reputation: 5534
Here's a debug tip for looking for mysterious exceptions: in Visual Studio, go to Debug -> Exceptions... and check "Thrown" for Common Language Runtime Exceptions. That way, whenever an exception gets fired the IDE will break. I've used that a lot to find exceptions that seem to get swallowed.
Don't forget to turn it off, though. :)
Upvotes: 1
Reputation: 22646
Any unhandled exceptions in background threads cause the runtime to terminate immediately. You need to catch and handle any exceptions in your async methods.
Upvotes: -1