Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start debugging on C# startup project in native-only mode

I have a MSVC2013 solution with C# (managed) and C++ (native) projects. One C# project is set as startup project. I want to start this project with debugging, which is usually achieved in devenv by simply pressing F5.

However, I want to start debugger in native-only mode (i.e. no managed debugging). I cannot achieve this behavior by changing settings of C# project: it only has an option "Enable native code debugging", which allows to enable or disable native debugging. The only standard way I know is to start application without debugging, and then attach to process with only native debugging chosen.

Is there a way to automate this process? Ideally, pressing one button should be enough to start native-only debugging. Perhaps some extension could simplify this task.


P.S. I have bumped into a nasty bug in mixed mode debugging, which breaks debugging completely in my case. This bug itself is not the topic of the question, it just explains why native-only debugging with C# startup project may be useful (and is useful to me personally).

like image 589
stgatilov Avatar asked Oct 23 '15 12:10

stgatilov


1 Answers

It is not very clear why you can't simply use Project > Properties > Debug tab > tick "Enable native code debugging". If you use VS2012 and up then do beware that you have to disable the new managed debugging engine, it is no longer compatible with C++/CLI code. Use Tools > Options > Debugging > General > tick "Use Managed Compatibility Mode".

But you can achieve what you want, simply select one of the native code projects as your startup project. Right-click > Set as Startup Project. And you must select the startup EXE, Right-click > Properties > Debugging > Command, change it to the C# executable. Breakpoints become active (colored solid red) as soon as the C# code loads your DLL.

like image 161
Hans Passant Avatar answered Nov 14 '22 01:11

Hans Passant