4

mvc 4 で Web アプリケーションを開発しました。開発マシンではすべて問題ありませんが、ライブ サーバーでは次のエラーが発生します。

ファイルまたはアセンブリを読み込めませんでした

「System.Web.Http、Version=4.0.0.0、Culture=neutral、PublicKeyToken=31bf3856ad364e35」またはその依存関係の 1 つ。モジュールには、アセンブリ マニフェストが含まれている必要がありました。

次の解決策を試しました。

  • dll ファイルをローカル ドライブから bin フォルダーにコピーしました
  • ホスティングでasp.net 4が有効になっていることを確認しました
  • web.config ファイルが正しく構成されていることを確認しました。

これが正確な画面トレースです。最後の行に .net バージョン 4 と asp.net バージョン 4 が表示されていることに注意してください。これは問題ではないと思います。それについて私を案内してください。

Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The module was expected to contain an assembly manifest.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The module was expected to contain an assembly manifest.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace: 


[BadImageFormatException: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The module was expected to contain an assembly manifest.]
   innovationtimes.MvcApplication.Application_Start() +0

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

ここにweb.configファイル全体があります

 <?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="PreserveLoginUrl" value="true"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  <connectionStrings>
    <!--<add name="DataContext" providerName="System.Data.SqlClient" connectionString="Data Source=pc1\SQLEXPRESS;Initial Catalog=itdb;User Id=sa;Password=12345;"/>-->

  </connectionStrings>
  <system.web>
    <customErrors mode="Off"></customErrors>
    <compilation debug="true" targetFramework="4.0"/>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
    </handlers>
  </system.webServer>
</configuration>
4

2 に答える 2

5

やっとやり遂げることができました。同様の問題を抱えている人にも役立つことを願っています。

犯人は発行ウィザードです。パブリッシュ ツールを使用してプロジェクトをパブリッシュしました。しかし、公開されたプロジェクトをアップロードすると、単に機能せず、system.web.http アセンブリが壊れていることが示されました。

どのように解決しましたか -

プロジェクトの bin フォルダーから system.web.http dll をアップロードして、発行ウィザードの dll を上書きしました。

私はさらに他のdllを求められ、それらすべてに対して同じことをしました。

エラーのある dll をすべて bin フォルダーの 1 つに置き換えるとすぐに、アプリケーションが動作し始めました。

Visual Studio パブリッシュ ウィザードのバグかどうかはわかりません。誰かがこの問題についてより良い考えを持っている場合は、ここに投稿して他の人の助けを求めてください。

于 2012-12-22T10:18:21.290 に答える
0

私も同じ問題を抱えていました。どういうわけか、発行ウィザードはリリース モードが気に入らなかった。リリース モードでは、system.web.http.dll の展開に失敗し続け、その後かみそりアセンブリにも失敗しました。パブリッシュ ウィザードの設定でデバッグ モードに変更したところ、ようやく機能しました。もちろん、これで解決するわけではありません。デバッグ モードでパブリッシュするという厄介な回避策です。または、VS パブリッシュ ウィザード以外のパブリッシュ手段を使用してください。

于 2013-04-14T06:10:27.003 に答える