加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – Asp.net mvc 4部署错误

发布时间:2020-12-16 06:25:52 所属栏目:asp.Net 来源:网络整理
导读:我已经在mvc 4中开发了一个Web应用程序.在开发机器上一切都很好,但是在实时服务器上它给了我以下错误. 无法加载文件或程序集 ‘System.Web.Http,Version=4.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The modul
我已经在mvc 4中开发了一个Web应用程序.在开发机器上一切都很好,但是在实时服务器上它给了我以下错误.

无法加载文件或程序集

‘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.

我尝试了以下解决方案:

>将dll文件从本地驱动器复制到bin文件夹
>检查我的主机是否启用了asp.net 4
>检查了web.config文件是否配置正确.

这是确切的屏幕跟踪.请注意,最后一行显示.net版本4以及asp.net版本4所以我认为它不是问题.请指导我.

Could not load file or assembly 'System.Web.Http,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,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,PublicKeyToken=31bf3856ad364e35' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging,set the registry value [HKLMSoftwareMicrosoftFusion!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 [HKLMSoftwareMicrosoftFusion!EnableLog].

Stack Trace: 


[BadImageFormatException: Could not load file or assembly 'System.Web.Http,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=pc1SQLEXPRESS;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.NETFrameworkv4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFramework64v4.0.30319aspnet_isapi.dll" preCondition="classicMode,bitness64" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
    </handlers>
  </system.webServer>
</configuration>

解决方法

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

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

我是怎么解决的 –

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

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

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读