I have been upgrading all our projects to target .NET framework 4.6.2 and I'm running into a maddening problem. When I run the application it runs fine. However, when I run the unit tests I get an assembly load failure:
=== Pre-bind state information ===LOG: DisplayName = System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified)LOG: Appbase = file:///C:/Source/FeatureBranch/Kernel/CDSCore.Tests/bin/DebugLOG: Initial PrivatePath = NULLLOG: Dynamic Base = NULLLOG: Cache Base = NULLLOG: AppName = NULLCalling assembly : Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.===LOG: This bind starts in default load context.LOG: Using application configuration file: C:\Source\FeatureBranch\Kernel\CDSCore.Tests\bin\Debug\CDSCore.Tests.dll.configLOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.LOG: GAC Lookup was unsuccessful.LOG: Attempting download of new URL file:///C:/Source/FeatureBranch/Kernel/CDSCore.Tests/bin/Debug/System.Runtime.CompilerServices.Unsafe.DLL.LOG: Assembly download was successful. Attempting setup of file: C:\Source\FeatureBranch\Kernel\CDSCore.Tests\bin\Debug\System.Runtime.CompilerServices.Unsafe.dllLOG: Entering run-from-source setup phase.LOG: Assembly Name is: System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aWRN: Comparing the assembly name resulted in the mismatch: Build NumberERR: 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.
So if I compare the two dlls (One in the CDSCore.Tests folder and another in a system dll dir CDSCore) See this:
They are the exact same file. However, if I open them in ildasm you see this which shows different assembly versions. How on earth is this the case?