Similar to this problem here:
Old Question about C# debugging
I’m trying to debug a library that’s used in multiple projects and is compiled using Intel’s C++ v 11 compiler (ie, not the standard compiler) in Visual Studio 2008. The current platform I’m using to debug is a C# program that calls the C++ method through a p/invoke.
Is there a way to debug into the C++ code (which has been compiled in debug mode) short of doing something like starting some huge loop in the C++ code and attaching a debugger to the process? Right now, the C# code just steps right over the C++ call.
I’ve set it so that I can debug managed and unmanaged/native code, as well as debug ‘not my code’, but those settings don’t seem to matter.
I really, really want to avoid adding the C++ project to the C# project; as I said, it’s a library that’s called by multiple programs, so doing so would have serious consequences to those other programs and maintenance.
The answer: Set the debugging executable and running directory for the dll, and then try to debug from the dll as a separate project. That is, load the intel project in one sln file, and then have the C# project in a different sln file.
Then, when you try to debug the dll via f5/the debug button, the executable will start, and the code will execute, up to whatever breakpoints you’ve set.
Make sure to have a post-build step to put the dll into the same directory as your C# executable; otherwise, the dll will be out of sync with the code that’s actually run, and the results will be strange (ie, breakpoints not lining up, etc).
Also, with this approach, you will lose edit and continue (or, if there’s a way to keep it, I don’t know of it), but at least you get to debug in.
(answer posted for @Dmitri Nesteruk)