Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 352
Liam Avatar asked Dec 20 '12 14:12

Liam


People also ask

Can you debug in C?

Gdb is a debugger for C (and C++). It allows you to do things like run the program up to a certain point then stop and print out the values of certain variables at that point, or step through the program one line at a time and print out the values of each variable after executing each line.

What does debug mean in C?

Debugging is a methodical process of finding and reducing the number of bugs (or defects) in a computer program, thus making it behave as originally expected.

What is a breakpoint in C?

A breakpoint, in the context of C#, is an intentional stop marked in the code of an application where execution pauses for debugging. This allows the programmer to inspect the internal state of the application at that point.


1 Answers

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.

like image 82
monstercoo Avatar answered Nov 15 '22 08:11

monstercoo