4

私は3つのプロジェクトで解決策を持っています:

Solution.Web.Core - 共通クラス
Solution.Web.Mvc - MVC 4
Solution.Web.Api - Web Api 2 aka ASP.NET 5.0 (beta-1) アセンブリの実行

MVC アプリケーションの子アプリケーション (IIS 内) として WebApi をセットアップしましたが、このプロジェクトを完全に分離するのに苦労しています。

Solution.Web.CoreASP.NET 4.0 アセンブリへの参照がいくつかあるため、このプロジェクトへの参照を追加するSolution.Web.Apiと、実行時に次の例外が発生します。

ファイルまたはアセンブリ 'System.Net.Http.Formatting、Version=5.0.0.0、Culture=neutral、PublicKeyToken=31bf3856ad364e35' またはその依存関係の 1 つを読み込めませんでした。見つかったアセンブリのマニフェスト定義がアセンブリ参照と一致しません。(HRESULT からの例外: 0x80131040)

ASP.NET の古いアセンブリ バージョンを参照しているにもかかわらず参照Solution.Web.Apiできるように、このエラーの発生を防ぐにはどうすればよいですか?Solution.Web.Core

注:エラーには「System.Net.Http.Formatting またはその依存関係の1つ」と表示されているため、正確に問題のあるアセンブリを特定する方法さえわかりません。

4

2 に答える 2

2

View セクションの Web.Config を

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, **Version=5.0.0.0**, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, **Version=5.2.3.0**, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
于 2015-03-03T09:55:01.573 に答える
1

MVC 5 + Web Api 2 からやり直すことで、この問題を解決しました。

ただし、このブログ投稿の回答を見つけたところ、おそらく私にとってはうまくいったようです。

MVC 4 プロジェクトが 5.0 ベータ アセンブリ (少なくともブログ投稿の CORS アセンブリ) とうまく連携できるようにするには、Web 構成を次のように変更します。

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:bcl="urn:schemas-microsoft-com:bcl">
  <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.Razor" 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="1.0.0.0-5.0.0.0" newVersion="5.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="EntityFramework" publicKeyToken="b77a5c561934e089" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
  </dependentAssembly>

于 2013-07-14T18:23:06.180 に答える