【问题标题】:FileLoadException: Could not load file or assembly (The assembly reference did not match the assembly definition found)FileLoadException:无法加载文件或程序集(程序集引用与找到的程序集定义不匹配)
【发布时间】:2014-02-25 09:30:46
【问题描述】:

我遇到了版本不匹配的问题,不知道如何解决。

情况

初始情况

  • Integration.DataExchange.Processing.Implementation 由 buildserver 构建 --> 7.0.85.27765
  • Integration.DataExchange.TestToolsIntegration.DataExchange.Processing.Test 是手动构建的 --> 7.0.85.1420
  • Integration.Infrastructure.Serialization.Test 使用它们并抛出异常

日志

来自测试的错误信息

Test method Integration.Infrastructure.Serialization.ProcessInfoSerializerTests.SerializeAndDeserializeShouldBehaveResultInfoWithSameValues threw exception: 
System.IO.FileLoadException: Could not load file or assembly 'Integration.DataExchange.Processing.Implementation, Version=7.0.85.1420, Culture=neutral, PublicKeyToken=f15342ffe5641632' 
or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

对应的融合日志

*** Assembly Binder Log Entry  (25.02.2014 @ 09:49:58) ***

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

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

=== Pre-bind state information ===
LOG: DisplayName = Integration.DataExchange.Processing.Implementation, Version=7.0.85.1420, Culture=neutral, PublicKeyToken=f15342ffe5641632
 (Fully-specified)
LOG: Appbase = file:///d:/sources/Core/Bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = QTAgent.exe
Calling assembly : Integration.Infrastructure.Serialization.Test, Version=1.0.453.2209, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\xxx\AppData\Local\Temp\tmp913E.tmp
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Integration.DataExchange.Processing.Implementation, Version=7.0.85.1420, Culture=neutral, PublicKeyToken=f15342ffe5641632
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///d:/sources/Core/Bin/Debug/Integration.DataExchange.Processing.Implementation.DLL.
LOG: Assembly download was successful. Attempting setup of file: d:\sources\Core\Bin\Debug\Integration.DataExchange.Processing.Implementation.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Integration.DataExchange.Processing.Implementation, Version=7.0.85.27765, Culture=neutral, PublicKeyToken=f15342ffe5641632
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

解决方案

我的想法

Integration.Infrastructure.Serialization.Test 使用 Integration.DataExchange.TestTools 版本 7.0.85.1420 中的函数。 TestTools 也想加载版本 1420 的 Integration.DataExchange.Processing.Implementation。但是只找到了 27765 个。

我不明白的地方

在每个参考中都是一个非特定版本。所以我认为版本无关紧要


CS 项目文件

Integration.DataExchange.TestTools.csproj

<ProjectReference Include="..\Processing\Interface\Integration.DataExchange.Processing.Interface.csproj">
  <Project>{A67C3F93-F3CA-4746-9E5F-36645CD1A206}</Project>
  <Name>Integration.DataExchange.Processing.Interface</Name>
</ProjectReference>

Integration.DataExchange.Processing.Test.csproj

<ProjectReference Include="..\Implementation\Integration.DataExchange.Processing.Implementation.csproj">
  <Project>{61BF5881-C4B1-47E0-9B68-C9517FE3302E}</Project>
  <Name>Integration.DataExchange.Processing.Implementation</Name>
</ProjectReference>

Integration.Infrastructure.Serialization.Test.csproj

<Reference Include="Integration.DataExchange.Processing.Implementation">
        <SpecificVersion>False</SpecificVersion>
    </Reference>
<Reference Include="Integration.DataExchange.Processing.Interface">
        <SpecificVersion>False</SpecificVersion>
    </Reference>
<Reference Include="Integration.DataExchange.Processing.Test">
  <HintPath>$(SolutionDir)Lib\Debug\DataExchange.Test\Integration.DataExchange.Processing.Test.dll</HintPath>
</Reference>
<Reference Include="Integration.DataExchange.TestTools">
  <HintPath>$(SolutionDir)Lib\Debug\DataExchange.Test\Integration.DataExchange.TestTools.dll</HintPath>
</Reference>

【问题讨论】:

    标签: c# .net reference .net-assembly


    【解决方案1】:

    还在所有其他 .csproj 文件中设置 SpecificVersion=false - 很可能是“Integration.DataExchange.Processing.Test.csproj”

    编辑: 因为错误消息指出:“无法加载程序集 XXX 或其依赖项之一”

    【讨论】:

    • 但这是一个项目参考,我认为这种类型无法设置特定版本?!? stackoverflow.com/questions/915712/…
    • @masterchris_99 似乎混合了项目参考和普通参考,您设法陷入了真正痛苦的境地。我只是检查了一个带有项目参考的 .net 程序集,这证实了你的情况。如果您有项目参考,还会考虑版本号。版本号总是一样的吗?如果是这样,您可以使用绑定重定向:msdn.microsoft.com/en-us/library/7wd6ex19%28v=vs.100%29.aspx
    • 没有自动构建的程序集的版本每晚更新。
    • @masterchris_99 我认为你只能将项目引用更改为普通引用并设置 SpecificVersion=false
    猜你喜欢
    • 2019-12-04
    • 2021-10-15
    • 1970-01-01
    • 1970-01-01
    • 2013-08-24
    • 2015-10-30
    • 1970-01-01
    • 2017-11-24
    • 1970-01-01
    相关资源
    最近更新 更多