Debug C # dll from C ++ - solutions through COM

I have a C ++ solution. Launch project - exe. The solution has a number of C # dlls (targeting the .NET Framework 2.0) that are registered for COM interoperability. When I put a breakpoint in C # code, I get a hollow red breakpoint with "No native symbols in symbol file"

I tried setting the Project Property Pages -> Debugging -> Debugger Type to Mixed in the start project, which calls the COM methods.

I checked Debug -> Windows -> Modules . He loaded my DLLs, and the symbol status is "No native symbols in symbol file" .

This is not the end of the world, because if I do Debug -> Start Without Debugging , and then Debug -> Attach to Process , changing Attach To: to Managed (v2.0, v1.1, v1.0) code, Native code . Then I hit breakpoints in both C ++ code and C # code.

So, I have a workaround, but I think that if I can do this by connecting to the process, I can do it just by debugging.

How can I hit my C # breakpoints just by doing Debug -> Start Debugging ?

+7
source share
3 answers

I was able to debug my C # dll from a C ++ project in VS2008 by doing the following:

In the properties of a C ++ project, go to Configuration Properties → Debugging. Set Debugger Type to Mixed. Attach should be set to None.

In the properties of the C # project on the Debug tab, set "Run external program" in the C ++ project executable file.

+4
source

I know this a little old, but I found a practical solution to the problem.

I had the same problem when using a C ++ application that uses a C # COM object. I tried several settings in Visual Studio on the C ++ and C # side. Nothing helps until I tried to manually launch the debugger.

you can use

 Debugger.Launch(); 

to manually run Debugger on your C # DLL. I know that this is not the best, but a practical way. In later production environments, you should remove the Debugger :) startup function.

Hi

+2
source

I'm not sure if this helps, but we work a lot with C # and C ++. I found this possible by placing the C ++ project and the C # project in the same solution and turning on “native debugging” in the C # project. Then I was able to jump back and forth between them during debugging.

+1
source

All Articles