我在Visual Studio 2013测试框架中有一个C#单元测试,用于测试CLI和本地代码。我想在执行C#单元测试时调查代码的本地部分。然而,运行测试-> 调试-> 所有测试会运行托管调试器,因此无法击中本地代码中的断点,并且无法像在混合模式调试器下运行程序时那样从C#-> C++/CLI代码进行跟踪。
例如,我单元测试中的这段代码:
[TestMethod]
public void TestRoundTripEvaluate()
{
var obj = new MyCLIObject();
var roundtripped = RoundtripXml( obj );
// I would like to trace into here to see why Equals returns false.
// But the definition for MyCLIObject is in a CPP file and cannot be navigated
// to running the unit test because Visual Studio starts the debugger as "managed only"
// when using Test -> Debug -> All Tests
Assert.IsTrue( obj.Equals( roundtripped ) );
}
查看单元测试项目的项目设置,发现在调试(Debug)选项下所有的设置都被禁用了,因此无法勾选"启用本机代码调试" (Enable Native Code Debugging),而这是一个普通程序所允许的行为。
我应该如何在运行VS C#单元测试时启用混合模式调试或仅本机代码调试?