ShimsContext.Create抛出了StackOverflowException

时间:2017-06-05 19:04:49

标签: c# unit-testing stack-overflow shim

运行单元测试时,我在ShimsContext.Create上遇到StackOverflowException。在下面的代码中,我可以打破Thread.Sleep(0),所以我知道ShimsContext.Create正在引发异常。我已经评论了其他所有内容。知道为什么会这样或者如何解决它?

    [TestMethod]
    public void MyTest()
    {
        Thread.Sleep(0);
        using (ShimsContext.Create())
        {
            //commented out test logic that needs shims
        }
    }

溢出的堆栈看起来像:

Microsoft.QualityTools.Testing.Fakes.dll!Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.TraceProfilerInstrumentationProvider.ProtectingContext.ProtectingContext() + 0x1f bytes 
Microsoft.QualityTools.Testing.Fakes.dll!Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.TraceProfilerInstrumentationProvider.AcquireProtectingContext() + 0x2d bytes    
Microsoft.QualityTools.Testing.Fakes.dll!Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.TraceProfilerInstrumentationProvider.DetourProvider(object receiver, System.RuntimeMethodHandle methodHandle, System.RuntimeTypeHandle declaringTypeHandle, System.RuntimeTypeHandle[] 

这三个电话无限重复。

0 个答案:

没有答案