Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation' after nuget package retargetting

1

There are many similar posts on SO on this error, unfortunately none of them helps.

I've upgraded solution projects to .NET 4.8 and afterwards issued a command to retarget nuget packages:

update-package -reinstall -ignoreDependencies

After this, unit tests fail with an error:

Message: System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified

Fusion logs output follows:

*** Assembly Binder Log Entry  (7/24/2019 @ 2:20:44 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\testhost.x86.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = C:\Users\mike\AppData\Local\Temp\d21152b7-1ec9-47aa-88ab-181259a56531
LOG: AppName = d21152b7-1ec9-47aa-88ab-181259a56531
Calling assembly : MongoDB.Driver.Core, Version=2.7.2.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\sources\Services\upgrade-net48\ProSynchronizationWorker.Tests\bin\Debug\ProSynchronizationWorker.Tests.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: Redirect found in application configuration file: 4.0.0.0 redirected to 4.0.2.0.
LOG: Post-policy reference: System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug/System.Runtime.InteropServices.RuntimeInformation.DLL.
LOG: Attempting download of new URL file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.DLL.
LOG: Attempting download of new URL file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug/System.Runtime.InteropServices.RuntimeInformation.EXE.
LOG: Attempting download of new URL file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.EXE.
LOG: All probing URLs attempted and failed.

I tried few things suggested

  1. Update app.config, add binding redirects
  2. Update System.Runtime.InteropServices.RuntimeInformation v4.3.0 & ystem.Runtime.InteropServices v4.3.0 in all projects that directly or indirectly reference MongoDB.
  3. Add System.Runtime & System.Runtime.InteropServices.RuntimeInformation binding redirects

Judging from the Fusion logs, it looks into GAC but doesn't find the assembly (which I can confirm v. 4.0.2.0 is in GAC_MSIL).

How can I get rid of this error ?

c#
.net
xunit
asked on Stack Overflow Jul 24, 2019 by Michael

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0