每次我使用 Nuget 安装任何东西时,它都会添加到我<Runtime><asseblyBinding>
的 web.config 中的部分:
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
显然我使用的是 MVC4,所以对 Razor 2.0.0.0 的引用会破坏事情,并引发以下运行时错误。
Could not load type 'System.Web.Razor.Parser.SyntaxTree.CodeSpan' from assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
它很容易修复,只需从 Web.Config 中删除 rouge 部分,但仍然非常烦人!任何人都知道为什么会发生这种情况,或者如何解决这个问题?
我正在使用 Nuget 包管理器版本 1.7.30402.9028