Asp.net MVC 4部署错误 [英] Asp.net mvc 4 deployment error

查看:217
本文介绍了Asp.net MVC 4部署错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了MVC的Web应用程序4.一切都在开发机器上很好,但它给我下面的错误现场服务器上。

无法加载文件或程序集


  

System.Web.Http,版本= 4.0.0.0,文化=中立,
  公钥= 31bf3856ad364e35或它的一个依赖。该
  模块应包含一个程序集清单。


我曾尝试以下解决方案:


  • 从本地驱动器复制dll文件到bin文件夹

  • 经过我的主机已经asp.net 4启用

  • 检查过的web.config文件中的配置是否正确。

下面是确切的屏幕痕迹。请注意,最后一行显示.NET版本4以及asp.net版本4,所以我认为这是没有问题的。请指引我就可以了。

 无法加载文件或程序集System.Web.Http,版本= 4.0.0.0,文化=中性公钥= 31bf3856ad364e35或它的一个依赖。该模块应包含一个程序集清单。说明:执行当前Web请求的执行过程中发生未处理的异常。请查看有关错误的详细信息的堆栈跟踪以及它起源于code。异常详细信息:System.BadImageFormatException:未能加载文件或程序集System.Web.Http,版本= 4.0.0.0,文化=中性公钥= 31bf3856ad364e35或它的一个依赖。该模块应包含一个程序集清单。源错误:当前Web请求的执行过程中生成了未处理的异常。有关异常的来源和位置信息可以使用异常堆栈跟踪下面确定。程序集加载跟踪:下列信息有助于确定程序集System.Web.Http,版本= 4.0.0.0,文化=中性公钥= 31bf3856ad364e35'无法加载。
警告:程序集绑定日志记录被关闭。
要启用程序集绑定失败日志记录,注册表值[HKLM \\软件\\微软\\融合!EnableLog](DWORD)设置为1。
注意:有一些与程序集绑定失败日志记录关联的性能损失。
要关闭此功能,请移除注册表值[HKLM \\软件\\微软\\融合!EnableLog。堆栈跟踪:
[BadImageFormatException:未能加载文件或程序集System.Web.Http,版本= 4.0.0.0,文化=中性公钥= 31bf3856ad364e35或它的一个依赖。该模块应包含一个程序集清单。]
   innovationtimes.MvcApplication.Application_Start()+ 0版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.272

下面是整个web.config文件

 <?XML版本=1.0&GT?;
<! -
  有关如何配置ASP.NET应用程序的更多信息,请访问:
  http://go.microsoft.com/fwlink/?LinkId=169433
   - >
<结构>
  <&的appSettings GT;
    <添加键=网页:版本值=2.0.0.0/>
    <添加键=网页:启用VALUE =FALSE/>
    <添加关键=preserveLoginUrlVALUE =真/>
    <添加键=ClientValidationEnabledVALUE =真/>
    <添加键=UnobtrusiveJavaScriptEnabledVALUE =真/>
  < /的appSettings>
  <&是connectionStrings GT;
    <! - <添加名称=的DataContext的providerName =System.Data.SqlClient的的connectionString =数据源= PC1 \\ SQLEX $ P $干燥综合征;初始目录=防止非法贩卖数据库;用户ID = SA;密码= 12345; /> - >  < /&是connectionStrings GT;
  <&的System.Web GT;
    <的customErrors模式=关>< /&的customErrors GT;
    <编译调试=真targetFramework =4.0/>
    <网页和GT;
      <&命名空间GT;
        <添加命名空间=System.Web.Helpers/>
        <添加命名空间=System.Web.Mvc/>
        <添加命名空间=System.Web.Mvc.Ajax/>
        <添加命名空间=System.Web.Mvc.Html/>
        <添加命名空间=System.Web.Routing/>
        <添加命名空间=System.Web.WebPages/>
      < /命名空间>
    < /页>
  < /system.web>
  < system.webServer>
    <验证validateIntegratedModeConfiguration =FALSE/>
    <模块runAllManagedModulesForAllRequests =真/>
    <&处理GT;
      <清除NAME =ExtensionlessUrlHandler-ISAPI-4.0_32bit/>
      <清除NAME =ExtensionlessUrlHandler-ISAPI-4.0_64bit/>
      <清除NAME =ExtensionlessUrlHandler - 集成 - 4.0/>
      <添加名称=ExtensionlessUrlHandler-ISAPI-4.0_32bitPATH =*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS模块=IsapiModulescriptProcessor ​​=%WINDIR%\\ Microsoft.NET \\框架\\ v4.0.30319 \\ ASPNET_ISAPI.DLLpreCondition = classicMode,runtimeVersionv4.0,bitness32responseBufferLimit =0/>
      <添加名称=ExtensionlessUrlHandler-ISAPI-4.0_64bitPATH =*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS模块=IsapiModulescriptProcessor ​​=%WINDIR%\\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ ASPNET_ISAPI.DLLpreCondition = classicMode,runtimeVersionv4.0,bitness64responseBufferLimit =0/>
      <添加名称=ExtensionlessUrlHandler - 集成 - 4.0PATH =*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONSTYPE =System.Web.Handlers.TransferRequestHandlerpreCondition =integratedMode,runtimeVersionv4.0/>
    < /处理器>
  < /system.webServer>
< /结构>


解决方案

我终于成功地完成它。希望它也将帮助那些有类似的问题。

罪魁祸首是发布向导。我使用发布工具发表我的项目。然而,当我上载发布的项目,它根本就没有工作,显示system.web.http组件损坏。

我没有

如何解决它 -

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

我进一步提示其他DLL和我的所有的人都做了相同的。

应用程序启动,因为我全部换成一个错误的dll从我的bin文件夹尽快工作。

我不知道这是否是使用Visual Studio中的错误发布向导与否。如果任何人有这个问题的更好的想法,请张贴在这里为他人的帮助。

I have developed a web application in mvc 4. Everything is fine on the development machine, however on the live server it is giving me the following error.

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.

I have tried the following solutions:

  • Copied dll files to the bin folder from my local drive
  • Checked that my hosting has asp.net 4 enabled
  • Have checked that web.config file is properly configured.

Here is the exact screen trace. Notice that the last line shows .net version 4 as well as asp.net version 4 so I assume it is not the problem. Please guide me on it.

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

Here is the entire web.config file

 <?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>

解决方案

I finally managed to get it done. Hope it will also help those with similar issues.

The culprit is publish wizard. I published my project using the publish tool. However when I uploaded the published project, it was simply not working and showing the system.web.http assembly is corrupt.

How did I resolved it -

I uploaded the system.web.http dll from the bin folder of my project to overwrite the dll of publish wizard.

I was further prompted for other dlls and I did same for all of them.

The application started working as soon as I replaced all the erroneous dlls with one from my bin folder.

I am not sure if it is a bug with visual studio publish wizard or not. if Anybody have better idea of this issue, please post here for help of others.

这篇关于Asp.net MVC 4部署错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆