Asp.net mvc 4部署错误

Mur*_*bul 4 deployment asp.net-mvc

我已经在mvc 4中开发了一个Web应用程序.在开发机器上一切都很好,但是在实时服务器上它给了我以下错误.

无法加载文件或程序集

'System.Web.Http,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.该模块应该包含一个程序集清单.

我尝试了以下解决方案:

  • 将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
Run Code Online (Sandbox Code Playgroud)

这是整个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>
Run Code Online (Sandbox Code Playgroud)

Mur*_*bul 5

我终于成功完成了它.希望它也能帮助那些有类似问题的人.

罪魁祸首是发布向导.我使用发布工具发布了我的项目.但是,当我上传已发布的项目时,它根本无法工作并显示system.web.http程序集已损坏.

我是怎么解决的 -

我从我项目的bin文件夹上传了system.web.http dll来覆盖发布向导的dll.

我被进一步提示进入其他dll,我为所有这些做了同样的事情.

一旦我用bin文件夹中的一个替换了所有错误的dll,应用程序就开始工作了.

我不确定它是否是Visual Studio发布向导的错误.如果有人对此问题有更好的了解,请在此处发帖寻求他人的帮助.