Debugging native (unmanaged) code in unit test

I have a .NET assembly written in C# which is using NUnit.

The tests in this assembly calls a C++/CLI-assembly.

The C++/CLI-assembly calls native/unmanaged C++ code.

When I try to debug a unit test using Resharper, Native debugging does not seem to be enabled in Visual Studio. This has the effect that I can not properly "step" in the native/unmanaged code in C++.

I currently use a cumbersome workaround:

1) Each test calls Debugger.Break(); the first thing it does.

2) I select to Run the unit test (not debug)

3) The Debugger.Break causes a dialog to be shown which allows me to select Visual Studio instance to perform the debugging.

4) I choose to manually select debugging type.

5) I select Native in the dialog which pops up.

6) I click OK

As mentioned, this is rather cumbersome. Anyone has a more straight-forward approach to debugging unit tests calling native code?


we're currently having the same issue,

is there a reason for this limitation ? it's really driving us mad as most of our code is in an underlying c++ library.

has anyone found a solution ?


Ditto.  Would be nice to have an option to select the debugging engines in the Resharper settings.


There's a rather easy solution for this problem:

- Ensure your unit test assembly is the startup project (even if you won't be hitting F5 to start it)

- Enable native debugging in the project settings of that project

If still it doesn't start with native debugging enabled, set an external project (typically your exe) as startup program in debugging settings and start the exe once with native debugging enabled. After that, unit test should start with native debugging.


Here's a link towards a report of the same issue with Visual Studio's own test explorer.

From my non-insider point of view, and as far as I can tell, the internal issue must have been resolved on their side, as stepping in native code p/invoked from C# unit tests works for me.


This issue prevents debugging with Microsoft Child Process Debugging Power Tool

Resharper 2020.1.2 does not use the project-level "Enable native code debugging" setting

Though this seemed to worked in the past


Anthony M is there a bug filed for this, and is it relevant for 2020.2 also?


It affects 2020.2

Found an existing issue (marked fixed)

The workaround posted on the issue seems to work (disable ReSharper -> Options -> General -> Read solution model directly from project/solution files' and reload the solution)


Anthony M thank you for letting us know about the problem, we are working on it (RSRP-476045).


Please sign in to leave a comment.