title: Yet another System.Runtime.InteropServices error
body: <p>Every project we have with MongoDB will, at one point of another, have a problem with the System.Runtime.InteropServices library that doesn't load.</p>
  
  <p>This time the error is interesting:</p>
  
  <p><a href="https://i.stack.imgur.com/ygTC0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ygTC0.png" alt="Interop load exception"></a></p>
  
  <p>The outer exception can't find the version 4.3.0.0 of the lib.
  But the inner exception can't find version 4.0.0.0</p>
  
  <p>Does anyone have an idea about that?</p>
  
  <hr>
  
  <p>More information about the problem:</p>
  
  <p><a href="https://i.stack.imgur.com/IFpNX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IFpNX.png" alt="enter image description here"></a></p>
  
  <p>So, NuGet has 4.3.0.0 installed</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;packages&gt;
    &lt;package id="System.Runtime" version="4.3.0" targetFramework="net462" /&gt;
    &lt;package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net462" /&gt;
  &lt;/packages&gt;
  </code></pre>
  
  <p><em>packages.config</em> confirms that I have 4.3.0.0 installed,</p>
  
  <p>however, <em>app.config</em> which always seem to be out of sync with reality:</p>
  
  <pre><code>  &lt;dependentAssembly&gt;
      &lt;assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
      &lt;bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /&gt;
    &lt;/dependentAssembly&gt;
  </code></pre>
  
  <p>A line was added about version 4.0.1.0</p>
  
  <p>In the same line.. the csproj is nonsense:</p>
  
  <pre><code>&lt;Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"&gt;
    &lt;HintPath&gt;x:\Packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll&lt;/HintPath&gt;
  &lt;/Reference&gt;
  </code></pre>
  
  <p>Since it claims to reference 4.0.1.0 with the path of 4.3.0.0</p>
  
  <p>There is something broken and it is always happening with that exact same lib; not just this project: anywhere I include MongoDB, this lib comes as a dependency and, every time, there are some random problems with it.</p>
  
  <p>When I try to load in manually:</p>
  
  <pre><code>        var Name = new AssemblyName("System.Runtime.InteropServices.RuntimeInformation, Version=4.3.0.0");
          var Asm = Assembly.Load(Name);
  </code></pre>
  
  <p>it fails as well.</p>
  
  <p>I am finding that System.Runtime.InteropServices.RuntimeInformation.dll does NOT get copied to the build folder, even though it's included in the project.</p>
  
  <hr>
  
  <p>I found a nasty workaround:
  if I include MongoDB in the main exe, even if I don't use it, it has a dependency on the Interop lib and this forced the lib to be copied to the build folder and then the subsequent calls work.</p>