title: Moq : FileNotFoundException: Could not load file or assembly 'System.Runtime'
body: <p>I'm trying to learn Moq, and unit testing and i've got an error i don't understand when trying to use Moq.</p>
  
  <p>The code below is pretty much copy-pasted from <a href="https://github.com/Moq/moq4/wiki/Quickstart" rel="noreferrer">https://github.com/Moq/moq4/wiki/Quickstart</a>. I'm using it because the error also occurs on the main project i am working on and i just want to limit and potential errors i've caused with my newbishness.</p>
  
  <p>System.Runtime has been downloaded, and it's referenced. </p>
  
  <p>Edit: Also i've tried version 4.0.0 and the error is still there.</p>
  
  <pre><code>using System;
  using NUnit.Framework;
  using Proje.Controllers;
  using Proje.Models;
  using Proje.DAL;
  using Moq;
  using System.Web.Mvc;
  using System.Runtime;
  
  
  namespace Proje.UnitTests.Controllers
  {
      [TestFixture]
      public class BaseControllerTests
      {
          public interface IFoo
          {
              Bar Bar { get; set; }
              string Name { get; set; }
              int Value { get; set; }
              bool DoSomething(string value);
              bool DoSomething(int number, string value);
              string DoSomethingStringy(string value);
              bool TryParse(string value, out string outputValue);
              bool Submit(ref Bar bar);
              int GetCount();
              bool Add(int value);
          }
  
          public class Bar
          {
              public virtual Baz Baz { get; set; }
              public virtual bool Submit() { return false; }
          }
  
          public class Baz
          {
              public virtual string Name { get; set; }
          }
  
          [Test]
          public void TestTest() {
  
              var mock = new Mock&lt;IFoo&gt;();
              mock.Setup(foo =&gt; foo.DoSomething("ping")).Returns(true);
              //Assert some stuff
          }
  </code></pre>
  
  <blockquote>
    <p>FileNotFoundException: Could not load file or assembly
    'System.Runtime, Version=4.1.2.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
    system cannot find the file specified.</p>
    
    <p>FileNotFoundException: Could not load file or assembly
    'System.Runtime, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
    system cannot find the file specified.</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;packages&gt;
    &lt;package id="Castle.Core" version="4.3.1" targetFramework="net471" /&gt;
    &lt;package id="EntityFramework" version="6.2.0" targetFramework="net471" /&gt;
    &lt;package id="Microsoft.AspNet.Mvc" version="5.2.6" targetFramework="net471" /&gt;
    &lt;package id="Microsoft.AspNet.Razor" version="3.2.6" targetFramework="net471" /&gt;
    &lt;package id="Microsoft.AspNet.WebPages" version="3.2.6" targetFramework="net471" /&gt;
    &lt;package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net471" /&gt;
    &lt;package id="Moq" version="4.9.0" targetFramework="net471" /&gt;
    &lt;package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net471" /&gt;
    &lt;package id="MSTest.TestFramework" version="1.3.2" targetFramework="net471" /&gt;
    &lt;package id="NUnit" version="3.10.1" targetFramework="net471" /&gt;
    &lt;package id="NUnit3TestAdapter" version="3.10.0" targetFramework="net471" /&gt;
    &lt;package id="System.Runtime" version="4.3.0" targetFramework="net471" /&gt;
    &lt;package id="System.Threading.Tasks.Extensions" version="4.3.0" targetFramework="net471" /&gt;
    &lt;package id="System.ValueTuple" version="4.4.0" targetFramework="net471" /&gt;
  &lt;/packages&gt;
  
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
    &lt;/configSections&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Runtime.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Text.RegularExpressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Linq" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.AspNet.TelemetryCorrelation" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-1.0.4.0" newVersion="1.0.4.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="8fb06cb64d019a17" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-2.8.1.0" newVersion="2.8.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="mssqllocaldb" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Edit: Log</p>
  
  <pre><code>*** Assembly Binder Log Entry  (9/20/2018 @ 7:49: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\2017\COMMUNITY\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\testhost.x86.exe
  --- A detailed error log follows. 
  
  === Pre-bind state information ===
  LOG: DisplayName = System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
   (Fully-specified)
  LOG: Appbase = file:///C:/Users/NAME/source/repos/Proj/Proj.UnitTests/bin/Debug/
  LOG: Initial PrivatePath = NULL
  LOG: Dynamic Base = NULL
  LOG: Cache Base = NULL
  LOG: AppName = Tests_16537946
  Calling assembly : (Unknown).
  ===
  LOG: This bind starts in default load context.
  LOG: Using application configuration file: C:\Users\NAME\source\repos\Proj\Proj.UnitTests\bin\Debug\Proj.UnitTests.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.1.2.0 redirected to 4.1.2.0.
  LOG: ProcessorArchitecture is locked to MSIL.
  LOG: Post-policy reference: System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
  LOG: GAC Lookup was unsuccessful.
  LOG: Attempting download of new URL file:///C:/Users/NAME/source/repos/Proj/Proj.UnitTests/bin/Debug/System.Runtime.DLL.
  LOG: Attempting download of new URL file:///C:/Users/NAME/source/repos/Proj/Proj.UnitTests/bin/Debug/System.Runtime/System.Runtime.DLL.
  LOG: Attempting download of new URL file:///C:/Users/NAME/source/repos/Proj/Proj.UnitTests/bin/Debug/System.Runtime.EXE.
  LOG: Attempting download of new URL file:///C:/Users/NAME/source/repos/Proj/Proj.UnitTests/bin/Debug/System.Runtime/System.Runtime.EXE.
  LOG: All probing URLs attempted and failed.
  </code></pre>