发布到Azure的网站后未能加载文件或程序集System.Web.Http.WebHost [英] Could not load file or assembly System.Web.Http.WebHost after published to Azure web site

查看:676
本文介绍了发布到Azure的网站后未能加载文件或程序集System.Web.Http.WebHost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个网络项目,并在Visual Studio中运行良好。但是,我得到了下面的错误后,发布到azurewebsites。什么会导致这个问题?


  

无法加载文件或程序集System.Web.Http.WebHost,
  版本= 5.0.0.0,文化=中性公钥= 31bf3856ad364e35'或
  它的一个依赖。在位于集清单定义
  不匹配的程序集引用。 (从HRESULT异常:
  0x80131040)


  
  

说明:在执行过程中发生未处理的异常
  当前Web请求。有关详情,请堆栈跟踪
  有关错误的信息以及它起源于code。


  
  

异常详细信息:System.IO.FileLoadException:无法加载文件或程序
  集System.Web.Http.WebHost,版本5.0.0.0 =文化=中立,
  公钥= 31bf3856ad364e35或它的一个依赖。该
  位于集清单定义不匹配的程序集
  参考。 (异常来自HRESULT:0x80131040)


  
  

源错误:


  
  

的执行过程中生成了未处理的异常
  当前Web请求。有关的起源和位置信息
  除了可以使用异常堆栈跟踪下面来识别。


  
  

程序集加载跟踪:下列信息可以帮助
  确定程序集System.Web.Http.WebHost,版本5.0.0.0 =,
  文化=中性公钥= 31bf3856ad364e35'无法加载。


  
  

警告:程序集绑定日志记录被关闭。要启用程序集绑定
  故障记录,设置注册表值
  [HKLM \\软件\\微软\\融合EnableLog!](DWORD)为1。注意:有
  在一些性能损失与程序集绑定失败有关
  日志记录。要关闭此功能,请移除注册表值
  [HKLM \\软件\\微软\\融合!EnableLog。


以下是web.config文件的一部分。

 <&的System.Web GT;
    <的customErrors模式=关/>
    <编译调试=真targetFramework =4.5/>
    <的httpRuntime targetFramework =4.5/>
    <身份验证模式=表格>
      <形式loginUrl =〜/帐号/登录超时=2880/>
    < /认证>
    <网页和GT;
      <&命名空间GT;
        <添加命名空间=System.Web.Helpers/>
        <添加命名空间=System.Web.Mvc/>
        <添加命名空间=System.Web.Mvc.Ajax/>
        <添加命名空间=System.Web.Mvc.Html/>
        <添加命名空间=System.Web.Optimization/>
        <添加命名空间=System.Web.Routing/>
        <添加命名空间=System.Web.WebPages/>
      < /命名空间>
    < /页>
  < /system.web>
  < system.webServer>
    <验证validateIntegratedModeConfiguration =FALSE/>
  <&处理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>
  <&运行GT;
    < assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
      < dependentAssembly>
        < assemblyIdentity名称=DotNetOpenAuth.Core公钥=2780ccd10d57b246/>
        < bindingRedirect oldVersion =1.0.0.0-4.0.0.0NEWVERSION =4.1.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=DotNetOpenAuth.AspNet公钥=2780ccd10d57b246/>
        < bindingRedirect oldVersion =1.0.0.0-4.0.0.0NEWVERSION =4.1.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Helpers公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-2.0.0.0NEWVERSION =2.0.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Mvc公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-4.0.0.0NEWVERSION =4.0.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.WebPages公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-2.0.0.0NEWVERSION =2.0.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=WebGrease公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =0.0.0.0-1.5.2.14234NEWVERSION =1.5.2.14234/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=的EntityFramework公钥=b77a5c561934e089文化=中性/>
        < bindingRedirect oldVersion =0.0.0.0-5.0.0.0NEWVERSION =5.0.0.0/>
      < / dependentAssembly>
    < / assemblyBinding>
  < /运行>


解决方案

DLL 在公布(部署环境)缺失。这就是为什么它是工作在当地即Visual Studio中而不是在Azure的网站环境的原因。

只是做复制本地=真正在装配的属性( System.Web.Http.WebHost ),然后做了重新部署,它应该工作的罚款。

如果您收到类似的错误,即一些其他装配丢失,然后进行组装copylocal = TRUE并重新部署,反复重复这一点 - 如果你不能确定它的依赖

I created a web project and it runs well in Visual studio. However, I got the following error after published it to azurewebsites. What can cause the issue?

Could not load file or assembly 'System.Web.Http.WebHost, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.IO.FileLoadException: Could not load file or assembly 'System.Web.Http.WebHost, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.WebHost, Version=5.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].

The following is part of web.config file.

  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <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.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  <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>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

解决方案

The dll is missing in the published (deployed environment). That is the reason why it is working in the local i.e. Visual Studio but not in the Azure Website Environment.

Just do Copy Local = true in the properties for the assembly(System.Web.Http.WebHost) and then do a redeploy, it should work fine.

If you get the similar error i.e. some other assembly missing, then make that assembly to copylocal=true and redeploy, repeat this iteratively - if you are unsure of its dependencies.

这篇关于发布到Azure的网站后未能加载文件或程序集System.Web.Http.WebHost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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