无法加载文件或程序集System.Web.Mvc或它的一个依赖 [英] Could not load file or assembly System.Web.Mvc or one of its dependencies

查看:3825
本文介绍了无法加载文件或程序集System.Web.Mvc或它的一个依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前正在对asp.net mvc5(旧MVC3项目)。
它建立得很好,但是当我开始这个项目,但是当我运行该项目我对着下面的错误。

 无法加载文件或程序'System.Web.Mvc或它的一个依赖。找到的程序集清单定义不匹配程序集引用。 (异常来自HRESULT:0x80131040)

不知道我该怎么才能解决这个问题,任何想法?

这是集加载跟踪:

  === pre-绑定状态信息===
日志:显示名称= System.Web.Mvc
 (部分)
警告:部分绑定信息是为组装供应:
警告:程序集名称:System.Web.Mvc |域ID:2
警告:如果仅提供集显示名称的一部分发生了一个部分绑定。
警告:这可能导致粘合剂加载了不正确的装配。
警告:建议为大会提供了一个完全指定的文字标识,
警告:一个由简单的名称,版本,区域性和公钥令牌。
警告:请参阅白皮书http://go.microsoft.com/fwlink/?LinkId=109270以获取更多信息和应对这一问题的共同解决方案。
日志:应用平台=文件:/// C:/用户/ joaki /来源/回购/ 2015-TimeAdministration /来源/ V2 / SalesWeb2 / TimeReportV2 /
LOG:初始PrivatePath = C:\\用户\\ joaki \\来源\\回购\\ 2015年,TimeAdministration \\来源\\ V2 \\ SalesWeb2 \\ TimeReportV2 \\ BIN
调用汇编:(未知)。
===
日志:此绑定的默认加载上下文开始。
日志:正在使用应用程序配置文件:C:\\用户\\ joaki \\来源\\回购\\ 2015年,TimeAdministration \\来源\\ V2 \\ SalesWeb2 \\ TimeReportV2 \\ web.config中
日志:使用主机配置文件:C:\\用户\\ joaki \\文档\\ IISEx preSS \\设置\\ aspnet.config
日志:从C使用计算机配置文件:\\ WINDOWS \\ Microsoft.NET \\框架\\ v4.0.30319 \\ CONFIG \\ machine.config中。
日志:没有被应用政策在这个时候(私人,自定义,局部的,或基于位置的程序集绑定)来引用。
日志:新的URL文件试图下载:/// C:/用户/ joaki /应用程序数据/本地/温度/ ASP.NET临时文件/根/ a90c5137 / 552c494a / System.Web.Mvc.dll程序。
日志:尝试新的URL文件下载:/// C:/用户/ joaki /应用程序数据/本地/温度/ ASP.NET临时文件/根/ a90c5137 / 552c494a / System.Web.Mvc / System.Web.Mvc.dll程序。
日志:新的URL下载尝试file:///C:/Users/joaki/Source/Repos/2015-TimeAdministration/Source/V2/SalesWeb2/TimeReportV2/bin/System.Web.Mvc.DLL.
日志:正在使用应用程序配置文件:C:\\用户\\ joaki \\来源\\回购\\ 2015年,TimeAdministration \\来源\\ V2 \\ SalesWeb2 \\ TimeReportV2 \\ web.config中
日志:使用主机配置文件:C:\\用户\\ joaki \\文档\\ IISEx preSS \\设置\\ aspnet.config
日志:从C使用计算机配置文件:\\ WINDOWS \\ Microsoft.NET \\框架\\ v4.0.30319 \\ CONFIG \\ machine.config中。
日志:在重定向应用程序配置文件中发现:4.0.0.1重新定向到5.2.3.0。
日志:后政策参考:System.Web.Mvc,版本= 5.2.3.0,文化=中性公钥= 31bf3856ad364e35
日志:新的URL文件试图下载:/// C:/用户/ joaki /应用程序数据/本地/温度/ ASP.NET临时文件/根/ a90c5137 / 552c494a / System.Web.Mvc.dll程序。
日志:尝试新的URL文件下载:/// C:/用户/ joaki /应用程序数据/本地/温度/ ASP.NET临时文件/根/ a90c5137 / 552c494a / System.Web.Mvc / System.Web.Mvc.dll程序。
日志:新的URL下载尝试file:///C:/Users/joaki/Source/Repos/2015-TimeAdministration/Source/V2/SalesWeb2/TimeReportV2/bin/System.Web.Mvc.DLL.
警告:比较程序集名称时发生不匹配:主版本
错误:未能完成组装(HR = 0x80131040)的设置。探测终止。

网络confgg:

 <?XML版本=1.0编码=UTF-8&GT?;
<! -
  有关如何配置ASP.NET应用程序的更多信息,请访问:
  http://go.microsoft.com/fwlink/?LinkId=301880
   - >
<结构>
    <&是connectionStrings GT;
    <添加名称=SaleswebEntities的connectionString =/>
  < /&是connectionStrings GT;<&的appSettings GT;
    <添加键=网页:版本值=3.0.0.0/>
    <添加键=网页:启用VALUE =FALSE/>
    <添加键=ClientValidationEnabledVALUE =真/>
    <添加键=UnobtrusiveJavaScriptEnabledVALUE =真/>
  < /的appSettings>  <&的System.Web GT;
    <编译调试=真targetFramework =4.5.1>
      <&集会GT;
        <添加组件=System.Data.Entity的,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089/>
      < /组件>
    < /编译>  <身份验证模式=表格>
    <形式loginUrl =〜/帐号/登录超时=2880/>
  < /认证>  <会员和GT;
    <供应商>
      <清/>
      <添加名称=AspNetSqlMembershipProviderTYPE =System.Web.Security.SqlMembershipProvider的connectionStringName =ApplicationServicesenablePasswordRetrieval =假enablePasswordReset设置=真requiresQuestionAndAnswer =假requiresUniqueEmail =假maxInvalidPasswordAttempts =5minRequiredPasswordLength =6minRequiredNonalphanumericCharacters =0passwordAttemptWindow =10的applicationName =//>
    < /供应商>
  < /会员>  <型材>
    <供应商>
      <清/>
      <添加名称=AspNetSqlProfileProviderTYPE =System.Web.Profile.SqlProfileProvider的connectionStringName =ApplicationServices的applicationName =//>
    < /供应商>
  < / profile文件>  < roleManager启用=false的>
    <供应商>
      <清/>
      <添加名称=AspNetSqlRoleProviderTYPE =System.Web.Security.SqlRoleProvider的connectionStringName =ApplicationServices的applicationName =//>
      <添加名称=AspNetWindowsTokenRoleProviderTYPE =System.Web.Security.WindowsTokenRoleProvider的applicationName =//>
    < /供应商>
  < / roleManager>  <网页和GT;
    <&命名空间GT;
      <添加命名空间=System.Web.Mvc/>
      <添加命名空间=System.Web.Mvc.Ajax/>
      <添加命名空间=System.Web.Mvc.Html/>
      <添加命名空间=System.Web.Routing/>
      <添加命名空间=System.Web.Helpers/>
      <添加命名空间=System.Web.WebPages/>
    < /命名空间>
  < /页>
  < /system.web>  < system.webServer>
    <验证validateIntegratedModeConfiguration =FALSE/>
    <模块runAllManagedModulesForAllRequests =真/>
  < /system.webServer>  <&运行GT;
    < assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
      < dependentAssembly>
        < assemblyIdentity名称=Newtonsoft.Json文化=中性公钥=30ad4fe6b2a6aeed/>
        < bindingRedirect oldVersion =0.0.0.0-7.0.0.0NEWVERSION =7.0.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Optimization公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-1.1.0.0NEWVERSION =1.1.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=WebGrease公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =0.0.0.0-1.6.5135.21930NEWVERSION =1.6.5135.21930/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=Antlr3.Runtime公钥=eb42632606e9261f文化=中性/>
        < bindingRedirect oldVersion =0.0.0.0-3.5.0.2NEWVERSION =3.5.0.2/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Helpers公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-3.0.0.0NEWVERSION =3.0.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.WebPages公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-3.0.0.0NEWVERSION =3.0.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Mvc公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-5.2.3.0NEWVERSION =5.2.3.0/>
      < / dependentAssembly>
    < / assemblyBinding>
  < /运行>< /结构>


解决方案

如果你仔细阅读融合日志您发布,它为您提供所需的信息。我将剥离下来的重要线路。

  LOG:尝试新的URL下载file:///C:/Users/joaki/Source/Repos/2015-TimeAdministration/Source/V2/SalesWeb2/TimeReportV2/bin/System.Web.Mvc.DLL.

该应用程序正在寻找System.Web.Mvc.dll程序。这是它决定你的Web应用程序的bin文件夹下的一种: C:\\Users\\joaki\\Source\\Repos\\2015-TimeAdministration\\Source\\V2\\SalesWeb2\\TimeReportV2\\bin\\System.Web.Mvc.DLL

接下来,检查,看看是否有任何程序集绑定重定向在你的web.config该DLL,并发现之一:

 日志:使用应用程序配置文件:C:\\用户\\ joaki \\来源\\回购\\ 2015年,TimeAdministration \\来源\\ V2 \\ SalesWeb2 \\ TimeReportV2 \\ web.config中
日志:在重定向应用程序配置文件中发现:4.0.0.1重新定向到5.2.3.0。
日志:后政策参考:System.Web.Mvc,版本= 5.2.3.0,文化=中性公钥= 31bf3856ad364e35

如果你在你的web.config看看,会有这样的:

 < dependentAssembly>
    < assemblyIdentity名称=System.Web.Mvc公钥=31bf3856ad364e35/>
    < bindingRedirect oldVersion =1.0.0.0-5.2.3.0NEWVERSION =5.2.3.0/>
  < / dependentAssembly>

然后,它会检查它在应用程序的bin目录中找到的System.Web.Mvc.dll程序是相同的版本:

 警告:比较程序集名称时发生不匹配:主版本
错误:未能完成组装(HR = 0x80131040)的设置。探测终止。

据抱怨主要版本不匹配。这是在4号版本的第一个数字。如果你回到在日志中,那是因为System.Web.Mvc.dll程序在你的bin文件夹其实是版本 4 .0.0.1,不是期望的 5 。 2.3.0:

  LOG:重定向在应用程序配置文件中找到:4.0.0.1重新定向到5.2.3.0。

您需要检查您的解决方案,以确保引用System.Web.Mvc所有项目都在寻找相同的,最新的版本。如果你看一下在错误列表的警告,你可能会找到版本不匹配警告此程序集。

更新引用

一个解决办法是右键点击在Visual Studio中的解决方案中,选择管理的NuGet软件包的解决方案......,并尝试更新项目中使用System.Web.Mvc的版本相同。

它还将帮助,如果你明确了事先你的bin文件夹中。

您也可以使用软件包管理器控制台,而不是在整个解决方案更新软件包:

 更新封装Microsoft.AspNet.Mvc -version 5.2.3.0

currently working on asp.net mvc5 (old mvc3 project). It builds just fine, but when I start the project but when I run the project I am facing the following error.

Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Not sure how I can can fix this, any ideas?

This is the Assembly Load Trace:

=== Pre-bind state information ===
LOG: DisplayName = System.Web.Mvc
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Web.Mvc | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/joaki/Source/Repos/2015-TimeAdministration/Source/V2/SalesWeb2/TimeReportV2/
LOG: Initial PrivatePath = C:\Users\joaki\Source\Repos\2015-TimeAdministration\Source\V2\SalesWeb2\TimeReportV2\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\joaki\Source\Repos\2015-TimeAdministration\Source\V2\SalesWeb2\TimeReportV2\web.config
LOG: Using host configuration file: C:\Users\joaki\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/joaki/AppData/Local/Temp/Temporary ASP.NET Files/root/a90c5137/552c494a/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Users/joaki/AppData/Local/Temp/Temporary ASP.NET Files/root/a90c5137/552c494a/System.Web.Mvc/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Users/joaki/Source/Repos/2015-TimeAdministration/Source/V2/SalesWeb2/TimeReportV2/bin/System.Web.Mvc.DLL.
LOG: Using application configuration file: C:\Users\joaki\Source\Repos\2015-TimeAdministration\Source\V2\SalesWeb2\TimeReportV2\web.config
LOG: Using host configuration file: C:\Users\joaki\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.1 redirected to 5.2.3.0.
LOG: Post-policy reference: System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/joaki/AppData/Local/Temp/Temporary ASP.NET Files/root/a90c5137/552c494a/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Users/joaki/AppData/Local/Temp/Temporary ASP.NET Files/root/a90c5137/552c494a/System.Web.Mvc/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Users/joaki/Source/Repos/2015-TimeAdministration/Source/V2/SalesWeb2/TimeReportV2/bin/System.Web.Mvc.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Web confgg:

    <?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
    <connectionStrings>
    <add name="SaleswebEntities" connectionString= ""/>
  </connectionStrings>

<appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>

  <system.web>
    <compilation debug="true" targetFramework="4.5.1" >
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
      </assemblies>
    </compilation>

  <authentication mode="Forms">
    <forms loginUrl="~/Account/LogOn" timeout="2880" />
  </authentication>

  <membership>
    <providers>
      <clear />
      <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
    </providers>
  </membership>

  <profile>
    <providers>
      <clear />
      <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
    </providers>
  </profile>

  <roleManager enabled="false">
    <providers>
      <clear />
      <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
      <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
    </providers>
  </roleManager>

  <pages>
    <namespaces>
      <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.Helpers" />
      <add namespace="System.Web.WebPages" />
    </namespaces>
  </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

</configuration>

解决方案

If you carefully read the fusion log you posted, it gives you the information you need. I'll strip it down to the important lines.

LOG: Attempting download of new URL file:///C:/Users/joaki/Source/Repos/2015-TimeAdministration/Source/V2/SalesWeb2/TimeReportV2/bin/System.Web.Mvc.DLL.

The app is looking for System.Web.Mvc.dll. It's resolved it to the one under your web app's bin folder: C:\Users\joaki\Source\Repos\2015-TimeAdministration\Source\V2\SalesWeb2\TimeReportV2\bin\System.Web.Mvc.DLL

Next, it checks to see if there is any assembly binding redirect for that DLL in your web.config, and finds one:

LOG: Using application configuration file: C:\Users\joaki\Source\Repos\2015-TimeAdministration\Source\V2\SalesWeb2\TimeReportV2\web.config
LOG: Redirect found in application configuration file: 4.0.0.1 redirected to 5.2.3.0.
LOG: Post-policy reference: System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

If you look in your web.config, there will be something like this:

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
  </dependentAssembly>

It then checks that the System.Web.Mvc.dll it's found in your app's bin directory is the same version:

WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

It complains that the Major Version mismatches. This is the first number in the 4-number version. If you go back in the log, that's because the System.Web.Mvc.dll in your bin folder is actually version 4.0.0.1, not the desired 5.2.3.0:

LOG: Redirect found in application configuration file: 4.0.0.1 redirected to 5.2.3.0.

You need to check your solution to make sure all projects that reference System.Web.Mvc are looking for the same, latest version. If you look at the Warnings in the Error List, you'll likely find warnings about version mismatches for this assembly.

Updating References

One solution is to right click on the Solution in Visual Studio, choose "Manage NuGet Packages for Solution..." and try to update the projects to use the same version of System.Web.Mvc.

It will also help if you clear out your bin folders beforehand.

You can also use the Package Manager Console instead to update the package across your solution:

Update-Package Microsoft.AspNet.Mvc -version 5.2.3.0

这篇关于无法加载文件或程序集System.Web.Mvc或它的一个依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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