We have a project consisting of many small tools.
They all use MongoDB, and there was not one of them that did not annoy me at one time or another with this error:
Fixed System.IO.FileNotFoundException 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 they all have the app.config file, which I donโt even know about the origin with the following contents:
<?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 Interop lib version 4.3.0, but in some file I have no idea what version 4.0.1.0 wants (note that there is not even the same number of digits). Usually this fix, removing lib, re-adding it and ... soon the same problem will reappear again, usually after some NuGet updates, etc.
It seems that this only happens in projects where we have MongoDB libraries, where the version number in NuGet does not synchronize with what the app.config file creates.
source share