Debugging .NET 2.0 Assembly from unmanaged Code in VS2010?

Posted on Dot net Slackers See other posts from Dot net Slackers
Published on Mon, 07 Jun 2010 00:00:00 GMT Indexed on 2010/06/07 21:32 UTC
Read the original article Hit count: 484

Filed under:
Ive run into a serious snag trying to debug a .NET 2.0 assembly that is called from unmanaged code in Visual Studio 2010. I maintain a host of components that using COM interop and custom .NET runtime hosting and ever since installing Visual Studio 2010 Ive been utterly blocked by VS 2010s inability to apparently debug .NET 2.0 assemblies when launching through unmanaged code. Heres what Im actually doing (simplified scenario to demonstrate): I have a .NET 2.0 assembly that is compiled for...

Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.



Email this Article

© Dot net Slackers or respective owner

Debugging .NET 2.0 assembly from unmanaged code in VS2010?

Posted by Rick Strahl on West-Wind See other posts from West-Wind or by Rick Strahl
Published on Mon, 07 Jun 2010 19:58:51 GMT Indexed on 2010/06/07 20:12 UTC
Read the original article Hit count: 483

Filed under:

I’ve run into a serious snag trying to debug a .NET 2.0 assembly that is called from unmanaged code in Visual Studio 2010. I maintain a host of components that using COM interop and custom .NET runtime hosting and ever since installing Visual Studio 2010 I’ve been utterly blocked by VS 2010’s inability to apparently debug .NET 2.0 assemblies when launching through unmanaged code.

Here’s what I’m actually doing (simplified scenario to demonstrate):

  • I have a .NET 2.0 assembly that is compiled for COM Interop
  • Compile project with .NET 2.0 target and register for COM Interop
  • Set a breakpoint in the .NET component in one of the class methods
  • Instantiate the .NET component via COM interop and call method

The result is that the COM call works fine but the debugger never triggers on the breakpoint.

If I now take that same assembly and target it at .NET 4.0 without any other changes everything works as expected – the breakpoint set in the assembly project triggers just fine.

The easy answer to this problem seems to be “Just switch to .NET 4.0” but unfortunately the application and the way the runtime is actually hosted has a few complications. Specifically the runtime hosting uses .NET 2.0 hosting and apparently the only reliable way to host the .NET 4.0 runtime is to use the new hosting APIs that are provided only with .NET 4.0 (which all by itself is lame, lame, lame as once again the promise of backwards compatibility is broken once again by .NET). So for the moment I need to continue using the .NET 2.0 hosting APIs due to application requirements.

I’ve been searching high and low and experimenting back and forth, posted a few questions on the MSDN forums but haven’t gotten any hints on what might be causing the apparent failure of Visual Studio 2010 to debug my .NET 2.0 assembly properly when called from un-managed code. Incidentally debugging .NET 2.0 targeted assemblies works fine when running with a managed startup application – it seems the issue is specific to the unmanaged code starting up.

My particular issue is with custom runtime hosting which at first I thought was the problem. But the same issue manifests when using COM Interop against a .NET 2.0 assembly, so the hosting is probably not the issue.

Curious if anybody has any ideas on what could be causing the lack of debugging in this scenario?

© Rick Strahl, West Wind Technologies, 2005-2010
kick it on DotNetKicks.com

© West-Wind or respective owner