简体   繁体   中英

Debug C# dll from C++ solution via COM

I have a C++ solution. The startup project is an exe. In the solution there are a number C# dlls (targeting .NET Framework 2.0) that are registered for COM interop. When I put a breakpoint in the C# code I get the hollow red breakpoint with "No native symbols in symbol file"

I have tried setting Project Property Pages -> Debugging -> Debugger Type to Mixed on the start-up project that calls the COM methods.

I have checked Debug -> Windows -> Modules . It has 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 the Attach To: to Managed (v2.0, v1.1, v1.0) code, Native code . Then I hit breakpoints in both the C++ code and C# code.

So I have my workaround but I reckon if I can do it by attaching to process - I should be able to do it by just debugging.

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

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

In the C++ project's properties, goto Configuration Properties -> Debugging. Set "Debugger Type" to Mixed. "Attach" should be set to No.

In your C# project properties, in the Debug tab, set the "Start External Program" to your C++ project's executable.

I know it's a little bit old but I found a practical solution for the problem.

I had the same problem while using a C++ application which uses a C# COM-Object. I tried several settings within Visual Studio on the C++ and C# side. Nothing helps until I tried manually launching the Debugger.

You can use

Debugger.Launch();

to manually start the Debugger on your C# DLL. I know this is not the best but a practical way. In later productive environments you have to remove the Debugger launch function :).

Regards

I am unsure if this will help but we work a lot with C# and C++. I found this to be possible by placing the C++ project and the C# project in the same solution and enabling "native debugging" in the C# project. Then I was able to jump back and forth between them while debugging.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM