views:

101

answers:

3

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.

A: 

Apparently this is a known bug with x64 machines.

The bug and a workaround is on Microsoft Connect.

Brian Ortiz
A: 

Any unhandled exceptions in background threads cause the runtime to terminate immediately. You need to catch and handle any exceptions in your async methods.

See this related question

Paolo
+1  A: 

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. :)

Ari Roth