We have a project made of a bunch of small tools.
All of them use MongoDB and there hasn't been one of them that hasn't annoyed me at one time or another with that error:
System.IO.FileNotFoundException occurred HResult=0x80070002
Message=Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
and all of them have an app.config file that I don't even know the origin of with the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
At the same time, NuGet has the following line:
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net462" />
So, obviously, I have the Interop lib version 4.3.0, but some file I have no clue about wants version 4.0.1.0 (note that there is not even the same number of digits). This is usually fixed by removing the lib, re-adding it and... soon, again, the same problem will come once more, usually after some NuGet updates, etc.
It seems to happen only on the projects where we have the MongoDB libs where the version number in NuGet gets out of sync with whatever creates the app.config file.