【问题标题】:System.Security.VerificationException on unit test单元测试中的 System.Security.VerificationException
【发布时间】:2014-07-02 10:27:26
【问题描述】:

以下是我的单元测试项目中的单元测试文件之一。 "RouteConfigTests.cs"

[TestInitialize]
        public void Initialise()
        {
            RouteTable.Routes.Clear();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }

        #region default route
        [TestMethod]
        public void RouteDefault_ValidValues_ValidResultExpected()
        {
            "~/".ShouldMapTo<MessagesController>(x => x.Index());
        }
        #endregion

以下是packages.config文件:

<packages>
  <package id="AutoMapper" version="2.2.0" targetFramework="net45" />
  <package id="FakeItEasy" version="1.21.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net45" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="MicrosoftWebMvc" version="2.0" targetFramework="net45" />
  <package id="Mvc4Futures" version="4.0.20710.0" targetFramework="net45" />
  <package id="MvcContrib" version="2.0.95.0" targetFramework="net45" />
  <package id="MvcContrib.TestHelper" version="2.0.95.0" targetFramework="net45" />
  <package id="RhinoMocks" version="3.6" targetFramework="net45" />
</packages>

下面是app.config文件:

 <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

当我尝试调试这个测试时,它给了我 System.Security.VerificationException 类型的异常 - 类型参数违反了类型参数 TController 的约束。

知道为什么会发生这种情况吗?以及如何解决?

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-4 unit-testing mvccontrib


    【解决方案1】:

    我在安装 Visual Studio 2012 的更新 4 后修复了它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-13
      • 2013-02-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多