Debugging a C++ dll ?

O

Ole

I have added a C++ dll to my solution where my main program (C#) is calling
the dll using DllImports but I got the message ""The breakpoint will not
currently be hit" when trying to debug my dll code - what should I do to
debug the dll?

Thanks
Ole
 
V

verbiest

I have added a C++ dll to my solution where my main program (C#) is calling
the dll using DllImports but I got the message ""The breakpoint will not
currently be hit" when trying to debug my dll code - what should I do to
debug the dll?

Thanks
Ole

This is what works for me:
1) Execute your main program without (!) the debugger attached (from
Visual Studio use CTRL+F5).
2) Manually attach a debugger. For instance in Task Manager right-
click your process and choose 'Debug'.
3) Select 'Manually choose the debugging engines' and make sure that
both the managed and unmanaged debugging engines are selected.

Now your breakpoint should be hit.

If the code you're trying to debug is executed during the startup of
your process, you might not have sufficient time to execute step 2. In
this case, add a call to 'System.Diagnostics.Debugger.Break()' to your
startup code. This will halt your program and attach a debugger. Here
too you will have to manually select the unmanaged debugging engine.

Kristof Verbiest
http://kristofverbiest.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top