升级ASP.NET MVC版本后发生此问题。
“System.Web.Mvc.ViewPage”类型含糊不清:它可能来自汇编......
答案 0 :(得分:12)
我看到您已经为自己提供了答案,但另一种解决方案是使用<runtime>
元素更新您的web.config,该元素重定向依赖程序集并指向正确的程序集:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<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>
</assemblyBinding>
</runtime>
请注意,从NuGet更新项目会对大多数程序集自动执行相同的操作。
答案 1 :(得分:5)
在解决方案资源管理器中,单击引用&gt; System.Web.Mvc。单击属性并设置Copy Local = True。
这样您就可以确保在项目中获得正确版本的MVC,而不依赖于GAC中安装的任何版本。此方法还允许您对MVC DLL进行bin部署。
答案 2 :(得分:2)
这解决了我的问题......
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Abstractions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Routing" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>