最近、MVC4で新しいWebアプリケーションを作成し、すべてのファイルをコピーして、最後にweb.configをマージすることにより、WebアプリをMVC3から4にアップグレードしました。すべてが既存のWebアプリで正常に機能しますが、今日、非常に奇妙なエラーに気づきました。デフォルトのダミー実装を使用して新しいAPIコントローラーを作成し、そのAPI(/ api / eventsなど)を参照すると、Could not load type
エラーが発生します。奇妙なことに、アプリを再構築してURLをもう一度ヒットすると、不平を言っている別のアセンブリのように見えます。主に、これら2つが交互に表示されます。
Could not load type 'System.Web.Razor.Parser.SyntaxTree.CodeSpan' from assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
と
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.
私の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>
そして、私の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" />
新しいmvc4Webアプリから「バニラ」を使用してweb.configをコピーしようとしましたが、それでも同じエラーが発生します(ファイルまたはアセンブリMicrosoft.Scriptingを読み込めませんでした)