Is there any way to debug c++ dll called from C# DllImport?
Both require turning on the same option: Project > Properties > Debug tab > tick the "Enable unmanaged code debugging" option.
You can now set a breakpoint in the native DLL code, it will turn from hollow to solid as soon as the C# project loads the DLL. And OutputDebugString() output will go to the Output window thanks to the unmanaged debugging engine being used.
If you run up a C++ debugger while your program is running, and then go to Debug->Attach To Process->Find your process and attach to it. You should be able to debug it.
Make sure that you have compiled your DLL with the debugger symbols. (.pdb) file and that they are in the directory where you run things from.
When attaching, change the "Attach to" value to "Native". The process should not be running under the managed code debugger - instead of "Debug", use the "Run" command to start.
Also, the DLL needs to be compiled with debug info for any sensible debugging to take place. Make sure you're not P/Invoking the Release build.
The OutputDebugString() should work regardless of debugging mode, however.