【问题标题】:Assembly Binding Old Reference Exception程序集绑定旧引用异常
【发布时间】:2012-03-23 02:58:16
【问题描述】:

在过去的 12 小时里,我一直在尝试解决程序集绑定问题,但运气不佳。上周,我已将解决方案中的所有项目从 EF 4.1.0.0 升级到 EF 4.3.1.0。今天早上我在一个现有的测试项目中添加了一些测试,清理并重新编译了解决方案。所有项目都编译时没有警告或错误。在项目中的任何地方调用实体框架时,我都会收到以下异常:

初始化方法 NutricityPPCTests.Common.DizzleProductExtensionsTests.TestSetup 抛出 例外。 System.IO.FileLoadException:System.IO.FileLoadException: 无法加载文件或程序集 'EntityFramework,版本 = 4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 或其之一 依赖关系。定位程序集的清单定义不 匹配程序集引用。 (HRESULT 异常:0x80131040)。

我启动了融合程序集绑定日志查看器,并找到了与异常对应的日志条目。我已经验证我的测试项目 MOMData 项目都引用了正确的 EF4.3.1.0 程序集。我确认项目文件中没有对 EF 4.1.0.0 的引用。我删除了两个项目中的 obj 和 bin 目录的内容。这个项目已经清理和重建了很多次,我的硬盘可能明天就要坏了。

*** Assembly Binder Log Entry  (3/22/2012 @ 5:55:11 PM) ***

The operation failed.
Bind result: hr = 0x80131040. No description available.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\QTAgent32.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = NUTRICITY0\awolske
LOG: DisplayName = EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 (Fully-specified)
LOG: Appbase = file:///C:/Users/awolske/Documents/NutricityWorkspace/Nutricity/NutricityPPCTests/bin/Release
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = QTAgent32.exe
Calling assembly : MomData, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\awolske\Documents\NutricityWorkspace\Nutricity\NutricityPPCTests\bin\Release\NutricityPPCTests.DLL.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/awolske/Documents/NutricityWorkspace/Nutricity/NutricityPPCTests/bin/Release/EntityFramework.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\awolske\Documents\NutricityWorkspace\Nutricity\NutricityPPCTests\bin\Release\EntityFramework.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

我还应该在哪里寻找旧的引用程序集?!?欢迎任何帮助,并非常感谢!提前感谢您的宝贵时间!

【问题讨论】:

  • 不是 MomData。它是一个名为 NutricityPPCTests 的程序集,仍然有旧的引用。

标签: visual-studio-2010 .net-4.0 entity-framework-4.3


【解决方案1】:

将以下内容添加到您的 web.config 文件中:

<runtime>
<assemblyBinding>
        <dependentAssembly>
          <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
        </dependentAssembly>
   </assemblyBinding>
</runtime>

【讨论】:

    【解决方案2】:

    我有同样的错误。我的解决方案中的大多数项目都引用了 Entity Framework 4.3.0.0 dll,但是当我检查解决方案中所有项目的引用时,我发现一些项目引用了 Entity Framework 4.1.0.0 dll。删除并用对 Entity Framework 4.3.0.0 dll 的新引用替换它们解决了问题。

    【讨论】:

    • 同样的错误,不幸的是 - 在任何其他项目中都没有参考。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    • 1970-01-01
    相关资源
    最近更新 更多