Skip to main content
 首页 » 编程设计

asp.net之无法从 HRESULT : 0x80131040 加载文件或程序集异常

2024年11月24日9itcoder

我创建了我的第一个 MVC 4 项目,它在本地服务器上完美运行。但是当我将其发布到本地文件夹并将文件夹内容上传到托管服务器时。我尝试运行它,但出现此错误:

Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The system cannot find the file specified. Can any one help me please?



网页配置:
<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="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> 
  </dependentAssembly> 
</assemblyBinding> 

P.S Web Forms 中的同一个项目适用于托管服务器。

请您参考如下方法:

终于找到答案了!!
转到引用资料 --> 在导致问题的 dll 文件上右键单击 --> 选择属性 --> 检查版本 --> 将属性中的版本与 Web 配置相匹配

<dependentAssembly> 
    <assemblyIdentity name="YourDllFile" publicKeyToken="2780ccd10d57b246"               culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-YourDllFileVersion" newVersion="YourDllFileVersion" /> 
  </dependentAssembly>