How can I debug an unhandled exception in managed code when called from COM?

I have a C # .NET component that is being called from an EXE exe outside the Process process.

I can run the debugger in Visual Studio 2005, running on my COM exe, which calls my .NET component. The exception is the control points, but the gap on the unprocessed "Original set of objects" excludes. I tried the following to no avail:

  • checked all CLR exceptions in the VS Exceptions dialog box
  • enabled "Break if exceptions intersect with AppDomain or managed / native borders"
  • unmanaged code debugging is enabled in my project program
  • debugging "Just My Code" is disabled
+8
debugging c # visual-studio-2005
source share
2 answers

What I usually do is add a call to System.Diagnostics.Debugger.Launch; at the entry point of my managed code. This will start the debugger if the program is not already active in debug mode. Keep in mind that you will need to delete this line after debugging is complete, since you do not want the debugger to start the call in the release version.

+3
source share

Instead of starting your programming with F5 you can run an unmanaged program and then attach to it:

For Visual Studio 2005:

  • Run (do not debug) an unmanaged project from Visual Studio using Ctrl+F5
  • Open the Attach to Process dialog box: Debug → Attach to Process ...
  • Click the "Attach to:" button: select ...
  • Choose: debug these types of code:
  • Check out these items: Managed, Native
  • Click OK
  • Select your process from the available processes.
  • Click "Attach"

This should include both managed and unmanaged debugging in an unmanaged process. Now you can set breakpoints or catch the first time exception in managed code if you have characters.

+1
source share

All Articles