In our project we was using below version of Bond Packages
<PackageReference Include="Bond.Runtime.CSharp">
<Version>5.3.1</Version>
</PackageReference>
<PackageReference Include="Bond.Core.CSharp">
<Version>5.3.1</Version>
</PackageReference>
<PackageReference Include="Bond.Core.CSharp">
<Version>5.3.1</Version>
</PackageReference>
And we updated version to 11.0.0 after updating that package we got one exception as belove
An exception of type 'System.IO.FileLoadException' occurred in Microsoft.Osgs.Infra.Monitoring.dll but was not handled in user code
Could not load file or assembly 'Bond, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
As my understanding Microsoft.Osgs.Infra.Monitoring.dll is pointing to Bond 1.0.0 version so when we had 5.3.1 version of Bond Packages it was generating Bond.dll with 1.0.0 version in target folder but when we are updating to 11.0.0 it is generating Bond.dll(11.0.0.100).
Based on above problem found some solution which I tried
- Add binding redirect in app.config for Bond dll but it is showing below error
<dependentAssembly>
<assemblyIdentity name="Bond" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-99.0.0.0" newVersion="11.0.0.100" />
</dependentAssembly>
An exception of type 'System.IO.FileLoadException' occurred in Microsoft.Osgs.Infra.Monitoring.dll but was not handled in user code
Could not load file or assembly 'Bond, Version=11.0.0.100, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.```
means binding is worked but not able to load that , I checked in target directory that Bond.dll it is available with this 11.0.0.100 version but still throwing same exception.
Fusion Log looks like this
```LOG: DisplayName = Bond, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Users/username/Source/Repos/project/target/distrib/Debug/AnyCPU/dev/WebApi/ProjectA/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ProjectA.exe
Calling assembly : Microsoft.CommonSchema.Services, Version=4.2.0.0, Culture=neutral, PublicKeyToken=872fbc9102191257.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\username\Source\Repos\project\target\distrib\Debug\AnyCPU\dev\WebApi\ProjectA\ProjectA.exe.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: 1.0.0.0 redirected to 11.0.0.100.
LOG: Post-policy reference: Bond, Version=11.0.0.100, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/project/target/distrib/Debug/AnyCPU/dev/WebApi/ProjectA/Bond.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\username\Source\Repos\project\target\distrib\Debug\AnyCPU\dev\WebApi\ProjectA\Bond.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Bond, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
WRN: Comparing the assembly name resulted in the mismatch: Major 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.```
You need to find a newer version of Microsoft.Osgs.Infra.Monitoring.dll that is compiled against Bond >= 6.0.
The strong name signing key for Bond changed in Bond 6.0 way back in 2017. Binding redirections are very hard (impossible?) to make work across public key changes.
You may need to repeat this process until you find and upgrade everything that references Bond < 6 to newer versions that reference Bond >= 6.
There is some more background in the following GitHub issues:
I think you work at Microsoft. So do I. If you need more help with this issue, find me in the company address book and send me an email.