Freigeben über


random debugger tip: catching COM exceptions

I was cleaning out some old mail and came across this tip.  You can tell it was a long time ago, because it really only matters if you're writing COM objects, something I haven't done in a long, long time.

Some parts of Visual Studio use COM as a layer to handle cross-thread calls and enable cross-machine remoting.  One of the downsides of this technology is that a COM exception in a server is caught by COM and converted to an HRESULT.  That HRESULT is harder to notice & catch in a debugger than the original exception.

However, there is a registry key that will change this behavior.  When this key is set, the exception is passed through normally, and can be detected & debugged through normal mechanisms.

The key is:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole]
"IgnoreServerExceptions"="Y"

(The real reason I'm blogging this is so that I can find it in the future if I ever write COM again. :-))

Comments