Mat*_*rts 5 asp.net asp.net-mvc asp.net-mvc-3 asp.net-web-api
我最近通过在MVC4中创建一个新的Web应用程序,并将所有文件复制完毕,最后合并web.config,将我的Web应用程序从MVC3升级到了4.一切都适用于现有的网络应用程序,但是我今天刚刚注意到一个非常奇怪的错误 - 如果我尝试使用默认的虚拟实现创建一个新的API控制器,然后浏览到该api(例如/ api/events),我收到一个Could not load type错误.奇怪的是,如果我重建应用程序,并再次点击URL,它似乎是一个不同的程序集,它主要是在这两个之间交替:
Could not load type 'System.Web.Razor.Parser.SyntaxTree.CodeSpan' from assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Run Code Online (Sandbox Code Playgroud)
和
Could not load file or assembly 'Microsoft.Scripting, Version=1.1.0.20, Culture=neutral, PublicKeyToken=7f709c5b713576e1' or one of its dependencies. The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)
我的web.config包含以下程序集绑定信息:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<!--<assemblyIdentity name="FluentValidation" publicKeyToken="a82054b837897c66" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" />-->
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" />
</dependentAssembly>
<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>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
而且我的packages.config看起来好像包含了所有正确的位:
<package id="AspNetMvc" version="4.0.20126.16343" />
<package id="AspNetRazor.Core" version="2.0.20126.16343" />
<package id="AspNetWebApi" version="4.0.20126.16343" />
<package id="AspNetWebApi.Core" version="4.0.20126.16343" />
<package id="AspNetWebPages.Core" version="2.0.20126.16343" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="Microsoft.Web.Optimization" version="1.0.0-beta" />
<package id="System.Net.Http" version="2.0.20126.16343" />
<package id="System.Net.Http.Formatting" version="4.0.20126.16343" />
<package id="System.Web.Http.Common" version="4.0.20126.16343" />
<package id="System.Web.Providers" version="1.1" />
<package id="System.Web.Providers.Core" version="1.0" />
Run Code Online (Sandbox Code Playgroud)
我甚至尝试使用来自新的mvc4网络应用程序的"vanilla"复制我的web.config,这仍然给我同样的错误(无法加载文件或程序集Microsoft.Scripting)
尝试从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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4046 次 |
| 最近记录: |