After calling a COM-dll component, C# exceptions are not caught by the debugger

Posted by shlomil on Stack Overflow See other posts from Stack Overflow or by shlomil
Published on 2010-05-09T11:24:31Z Indexed on 2010/05/09 11:28 UTC
Read the original article Hit count: 216

I'm using a COM dll provided to me by 3rd-party software company (I don't have the source code). I do know for sure they used Java to implement it because their objects contain property names like 'JvmVersion'.

After I instantiated an object introduced by the provided COM dll, all exceptions in my C# program cannot be caught by the VS debugger and every time an exception occurs I get the default Windows Debugger Selection dialog (And that's while executing my program in debug mode under a full VisualStudio debugging environment).

To illustrate:

throw new Exception("exception 1");
m_moo = new moo();   // Component taken from the COM-dll
throw new Exception("exception 2");

Exception 1 will be caught by VS and show the "yellow exception window".

Exception 2 will open a dialog titled "Visual Studio Just-In-Time Debugger" containing the text "An unhandled win32 exception occurred in myfile.vshost.exe[1348]." followed by a list of the existing VS instances on my system to select from.

I guess the instantiation of "moo" object overrides C#'s exception handler or something like that. Am I correct and is there a way to preserve C#'s exception handler?

© Stack Overflow or respective owner

Related posts about c#

Related posts about jvm