为什么我的测试与System.Security.VerificationException失败?我的、测试、System、Security

2023-09-03 02:57:16 作者:来我长街

我在移植我的项目从VS2008到VS2010的一个过程。现在,我转换我的所有项目的解决方案,以.NET 4.0(客户端配置文件),当我运行测试,几乎所有的测试失败,出现以下异常:

I'm in the process of migrating one of my projects from VS2008 to VS2010. Now that I converted all of my projects in the solution to .NET 4.0 (Client Profile) when I run the test harness, almost all tests fail with the following exception:

System.Security.VerificationException:   操作可能动摇   运行时。

System.Security.VerificationException: Operation could destabilize the runtime.

我一直无法确定为什么这种异常发生。测试运行所有罚款当我在调试模式下运行它们。

I've been unable to determine why this exception occurs. The tests run all fine when I run them in debug mode.

整个解决方案可供下载这里。

The entire solution is available for download here.

任何人都可以点我朝着正确的方向?

Can anyone point me in the right direction?

推荐答案

这个问题似乎是与您激活code覆盖。禁用code覆盖解决了这个问题。你可以把你的AssemblyInfo.cs以下内容:

The problem seems to be related to the Code Coverage you activated. Disabling code coverage solves the issue. You could put the following in your AssemblyInfo.cs:

[assembly: SecurityRules(SecurityRuleSet.Level1, SkipVerificationInFullTrust = true)]

和激活code覆盖。