I have a C# windowed application that needs to make use of a third-party API, which is offered only in C. To solve this problem, I've created three projects within VS2008: two C# projects and an empty C++ project. One C# project is my "Wrapper" project, responsible only for producing managed code that calls the C DLL. The other C# project is the windowed application, which makes use of the Wrapper project; let's call this the GUI project.
Inside the C++ project, I've created several C files (*.c) that utilise the third-party API and export (dllexport) suitable functions. I can successfully compile this project into a DLL and have had no problems in calling these functions from my Wrapper project. In case it's relevant, my Wrapper project uses DllImport attributes to reference these functions.
My C++ project has a post-build event that copies the resulting DLL into the output directory of my GUI C# project so that it's picked up at execution time. This feels a bit grim, but it's the only way I've figured out how to do this. My GUI project has a dependency on my Wrapper project, which has a dependency on the C++ project.
What I'm struggling to do, however, is debug (i.e. step-through) my C project code. I've tried to set a breakpoint within the C code in the hope that it would be caught when my C# code executes the relevant function. Unfortunately, as soon as I run my C# application, the IDE warns me that the C breakpoints will never be executed: "No symbols have been loaded for this document."
Any help with this would be greatly appreciated. Here are some things I've played with, but to no avail:
Ensuring the .pdb file has the same timestamp as the DLL file. This hint was followed after a random Google suggested the "No symbols" error could be caused by this.
I've selected "Enabled unmanaged code debugging" in both my C# project properties.
I've tried setting a breakpoint in my C# call just prior to an invocation of one of the DLL methods and attempted to step into the DLL. This didn't work either, it simply stepped over the function.