升级到MVC 5.2.0.0导致异常"找不到方法:'布尔System.Web.WebPages.BuildManagerWrapper.IsNonUpdateablePrecompiledApp"

时间:2014-08-13 05:59:03

标签: asp.net asp.net-mvc nuget asp.net-webpages

我刚升级到Mvc 5.2.0.0并在浏览器(IE9)中启动Web应用程序时开始出现此异常:

  

[MissingMethodException:找不到方法:&#39; Boolean System.Web.WebPages.BuildManagerWrapper.IsNonUpdateablePrecompiledApp(System.Web.Hosting.VirtualPathProvider,Microsoft.Internal.Web.Utils.IVirtualPathUtility)&#39;。] < / p>

[stack trace snipped]

this MSDN Forums link我明白,很可能是某些旧版本的System.Web.WebPages.dll在“临时ASP.NET文件”中徘徊不去。夹。我清理了临时ASP.NET文件夹,但无济于事。我已经清理并重建了解决方案,但没有运气。我还检查了对DLL的引用 - 它们都已正确更新。

我的Web.config(相关部分)如下所示:

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
  </dependentAssembly>
</assemblyBinding>

2 个答案:

答案 0 :(得分:4)

重新安装Microsoft ASP.NET网页NuGet包将解决您的问题:

Install-Package Microsoft.AspNet.WebPages

答案 1 :(得分:1)

在我的情况下,问题是GAC版本和NuGet版本之间存在冲突,因此当我删除c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.WebPages文件夹并进行重建时,它开始正常工作而没有此异常。

我想前段时间我用MVC 4安装了System.Web.WebPages,当我尝试使用MVC 5时,它仍然使用GAC版本,因为它仍然有3.0.0版本,而不是3.2,因为它有实际上。