Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have C# application which is referencing VC++ dll.
The reference is through interface(Interop.some.dll)

I have to debug the VC++ code by running C# application how do i achieve this?

I cannot attach the process from VC++ code because the C# code is referencing Interop.Some.dll and hence it will not bother to call the VC++ code....!!!
Posted
Updated 12-Aug-15 8:55am
v2
Comments
[no name] 12-Aug-15 15:12pm    
think about you use e.g. psapi.dll (from MS). No source, no debug Information. Do you expect you can debug/trace these methods?
Sergey Alexandrovich Kryukov 12-Aug-15 15:18pm    
Let's assume there is debug information, and perhaps this is the inquirer's project, otherwise there is nothing to talk about. If this is so, debugging is quite possible.
But, if this is the inquirer's C++ project, I would advice to change it to C++/CLI, then it can make an assembly to be really referenced, not P/Invoked. This is the best way to work with C++, even unmanaged code.
—SA
Sergey Alexandrovich Kryukov 12-Aug-15 15:19pm    
As this is the same process, you can always set a breakpoint and debug. But I would rather suggest to use C++/CLI and/or mixed-mode (managed + unmanaged) C++/CLI project; please see my comment above.
Even with a separate process, you can always attach the debugger to a process.
You only need to have all debug information, source code, everything needed for the debugging.
—SA
Philippe Mori 13-Aug-15 12:39pm    
It is not clear if you also build that DLL. Also, there are a few debugging options that affect the debugging experience. There are options to debug only your code and options to select debugging engine to use...

1 solution

Short answer: you can't.
Because the saying The one skilled don't ask, and the one who ask don't have skills to do it applies. A simply trick will not be enough to give you the skills.

Long answer:
1) You can easily use the debugger in your C# code to analyse arguments and results when you call the dll. this is within your reach.

2) If you have the source code for the dll, the easiest way to debug it, is to make a test bed that will not be included in the final dll. This test bed is the place you use to debug what will be the dll.

3) if you don't have source code, you can always debug the machine code but it require advanced skills in debugging, and only experience will give you the skills, this kind of skills is only gained by learning of your failures.

For case 3, I recommend to build a dummy dll with functions that use simple arguments and results and see how it look on debuger.
 
Share this answer
 

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