Click here to Skip to main content
15,870,165 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Environment:
Visual C++ 6.0 (Exe) - using ATL COM (developed using Visual studio 6.0 - msdev); it calls a C# dll (developed using Visual studio 2010 - .NET Framework 2.0).

I would like to debug a C# dll from a VC++ exe. Both the files were built in Debug mode. In the C# dll (Visual Studio 2010), I have tried the following:
1. Setting the Project Properties -> Debug -> Enable unmanaged code debugging.
2. In the C# dll I have kept breakpoint in the constructor and the method being called from the VC++ exe; Debug -> Attach To Process -> msdev (VC++ exe). On doing so, I get the message "The breakpoint will not currently be hit. No symbols have been loaded for this document."

FYI: I am able to Debug the same C# dll (Managed code) from a VB6.exe (unmanaged code) using Debug -> Attach to Process.


Thanks in Advance.
Posted
Updated 28-Sep-11 20:58pm
v3

As possibility (I haven't tried it) if you just want to debug the C# itself then add the following at some early point (ctor or even add a static ctor.)

System.Diagnostics.Assert.Debug(false);

Then have the IDE up with the C# dll code loaded. When the above statement is hit you should get dialog babbling about something (I don't read it anymore) but among several buttons there is a Retry button. Hit it then it will ask which IDE to use - pick the one with your loaded C# code.

Once you do that you can add appropriate break points and they will hit every time as long as you don't restart the original app. The original line can be Ignored (another button) after the first hit as long as you have appropriate break points.
 
Share this answer
 
use System.Diagnostics.Debugger.Break();
will work as long as it is not a COM dll
 
Share this answer
 
Comments
Nelek 12-Jun-14 5:47am    
You came 3 years late ;P

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900