Failed binding redirection. What "run-from-source" phase stands for in Fusion logs?

0

I'm facing an issue with failing assembly binding redirection that I can't understand.

I have a binding redirection defined in the following way for test project:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.4.1.0" newVersion="4.4.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

The project is using SDK format <Project Sdk="Microsoft.NET.Sdk"> and is build in VS2019 v16.7.2.

When tests are executed using built-in test runner the following runtime exception is thrown:

OneTimeSetUp: System.IO.FileLoadException : Could not load file or assembly 'Castle.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
      ----> System.IO.FileLoadException : Could not load file or assembly 'Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have enabled Fusion Logs to see why runner fails to load the assembly:

*** Assembly Binder Log Entry  (02-Oct-20 @ 16:39:34) ***

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\2019\Professional\Common7\IDE\Extensions\TestPlatform\testhost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
 (Fully-specified)
LOG: Appbase = file:///C:/Users/_.__/src/_/Artifacts/IntegrationTests/x64/Debug/net472/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Tests_373511859
Calling assembly : Castle.Windsor, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\_.__\src\_\Artifacts\IntegrationTests\x64\Debug\net472\_IntegrationTest.dll.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.4.1.0.
LOG: Post-policy reference: Castle.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/_.__/src/_/Artifacts/IntegrationTests/x64/Debug/net472/Castle.Core.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\_.__\src\_\Artifacts\IntegrationTests\x64\Debug\net472\Castle.Core.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
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.

I have it double checked and the version of the file "..\Artifacts\IntegrationTests\x64\Debug\net472\Castle.Core.dll" is as expected 4.4.1.0 but for unknown reason logs say that it is 4.0.0.0

I have noticed that probing fails in "run-from-source" phase. Does it mean that the assembly is loaded from different location that is mentioned in the logs?

At my actual knowledge this behavior looks like an error in the binding mechanism.

I'm looking forward for some tips that will help me finding out a root cause of the issue.

sdk
visual-studio-2019
assembly-binding-redirect
asked on Stack Overflow Oct 2, 2020 by Bartosz Kurczyński • edited Oct 5, 2020 by Bartosz Kurczyński

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0