Debugging Native Code

I have a C # service calling a C DLL that was originally written in VC6.

There is an error in the DLL that I am trying to verify.

After a nightmare trying to get debugging work, I eventually added a dll to the VS2005 solution containing C # Service, and added the necessary _CRT_SECURE_NO_WARNINGS .

The debug version of the service is logged using the "installutil.exe" tool.

I can make the debugger break just before the line where the dll is entered by calling System.Diagnostics.Debugger.Break(); .

I found several instructions on the network regarding the transition to debugging unmanaged code and enabled the "Enable unmanaged code debugging" checkbox, I also tried to enable the options "Export"> "Debugging-> Native" Load DLL and "Enable RPC debugging" (although this is not COM ) I also copied the dll debug and .pdb to the same bin directory as the service.

However, unmanaged code is not part of it, which I really need.

UPDATE I found the Debug Type in the properties of the DLL and set it to “Mixed” as suggested by several sites, but to no avail.

UPDATE2 . My project now issues the debugging DLL and pdb to the same directory as the debugging service. DLL debugging still not possible.

+4
source share
3 answers

In the end, I created a console application and recreated all the previous calls to make sure that the call will act the same as in the actual service, with the actual parameters when it got there.

I wrote my patch and the resulting code to my site .

0
source

Try setting unmanaged code as a run. I know this doesn't make sense, but I remember that it works for a very similar project.

Since the DLL does not have an executable file associated with it, when you try to start it, a request appears to launch the application. Go to your C # application and then you will be well off.

Happy debugging!

EDIT: It has been a while, but I think the Mixed debug type is correct

+2
source

There is a workaround in Visual Studio 2013. Launch the application from the cmd line. When System.Diagnostics.Debugger.Break(); is deleted System.Diagnostics.Debugger.Break(); , the Visual Studio Just-In-Time Debugger window should appear. Check the "Manually select debugging mechanisms" checkbox, click "Yes" and make sure that the "Native" engine is checked. Click OK. Now you can enter your own code as if you had executed the code from VS.

0
source

Source: https://habr.com/ru/post/1305205/


All Articles