Max
Max

Reputation: 20014

Visual Studio Just-in-Time Debugger quits immediately

I have a WinForms managed application which calls into a native C++ dll. I have enabled mixed managed and unmanaged debugging for the project and I'm able to step into the unmanaged code when debugging the project. I'm interested in JIT debugging because it's much faster to run the debug build outside the debugger and start debugging only after some assertion is violated. JIT Debugger works fine, when the exception is raised in the managed code. It also work when I JIT debug a standalone C++ application. But whenever an exception is raised inside the unmanaged code which is invoked from the WinForms application, the JIT debugger quits immediately after I initiate the debugging session. I have enabled all the JIT debuggers in Options/Debugging/Just-In-Time list. Is this scenario supported at all?

UPDATE

I've run some more tests, and I can see that

  1. This problem is not specific to WinForms applications. JIT Debug also fails when a managed console application calls into a native dll, which raises an assertion exception.
  2. The problem does not seem to depend on framework version. I tried versions 3.5, 4, 4.5, 4.6.
  3. The debugger also fails to break on an assertion exception in the unmanaged code, when I attach the debugger to its managed host application.

Upvotes: 0

Views: 281

Answers (2)

Max
Max

Reputation: 20014

I feel stupid. The solution was right in front of me. There's an option in Visual Studio Just-In-Time Debugger dialog. It's called "Manually choose the debugging engines". Both Managed and Native engines have to be selected.

Upvotes: 0

Euclid Ye
Euclid Ye

Reputation: 521

I have gone through this situation before. I think the problem is that the exception is uncatched by debugger.

I did the following and maybe this would be helpful.

Click Debug->Windows->Exception Settings.

Or you just search "exception" at quick Launch.

You may find a lot of exception is not catched by default setting.

Upvotes: 0

Related Questions