title: Unit-Test AspNetCore with full .NET Framework
body: <p>While testing a Asp.NetCore (2.2) with full .NET Framework (4.7.2) with Unit-Tests (MSTest 1.3.2) with the help of the Microsoft.AspNetCore.TestHost (2.2.0) NuGet, I receive following exception</p>
  
  <pre><code>System.IO.FileNotFoundException: Could not load file or assembly 'System.Buffers, Version=4.0.2.0
  </code></pre>
  
  <p>However, I did choose <code>Microsoft.AspNetCore.TestHost 2.2.0</code> and downloaded all dependencies automatically. Hence, the packages.json looks like following:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;packages&gt;
    &lt;package id="EntityFramework" version="6.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.Hosting" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.Hosting.Abstractions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.Http" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.Http.Abstractions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.Http.Extensions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.Http.Features" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.TestHost" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.AspNetCore.WebUtilities" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Configuration" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Configuration.Abstractions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Configuration.Binder" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Configuration.FileExtensions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.DependencyInjection" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.FileProviders.Abstractions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.FileProviders.Physical" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.FileSystemGlobbing" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Hosting.Abstractions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Logging" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Logging.Abstractions" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.ObjectPool" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Options" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Extensions.Primitives" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="Microsoft.Net.Http.Headers" version="2.2.0" targetFramework="net472" /&gt;
    &lt;package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net472" /&gt;
    &lt;package id="MSTest.TestFramework" version="1.3.2" targetFramework="net472" /&gt;
    &lt;package id="Newtonsoft.Json" version="11.0.2" targetFramework="net472" /&gt;
    &lt;package id="System.Buffers" version="4.5.0" targetFramework="net472" /&gt;
    &lt;package id="System.Collections.Immutable" version="1.5.0" targetFramework="net472" /&gt;
    &lt;package id="System.ComponentModel.Annotations" version="4.5.0" targetFramework="net472" /&gt;
    &lt;package id="System.Data.SQLite" version="1.0.109.2" targetFramework="net472" /&gt;
    &lt;package id="System.Data.SQLite.Core" version="1.0.109.2" targetFramework="net472" /&gt;
    &lt;package id="System.Data.SQLite.EF6" version="1.0.109.0" targetFramework="net472" /&gt;
    &lt;package id="System.Data.SQLite.Linq" version="1.0.109.0" targetFramework="net472" /&gt;
    &lt;package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net472" /&gt;
    &lt;package id="System.IO.Pipelines" version="4.5.2" targetFramework="net472" /&gt;
    &lt;package id="System.Memory" version="4.5.1" targetFramework="net472" /&gt;
    &lt;package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" /&gt;
    &lt;package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net472" /&gt;
    &lt;package id="System.Runtime.CompilerServices.Unsafe" version="4.5.1" targetFramework="net472" /&gt;
    &lt;package id="System.Text.Encodings.Web" version="4.5.0" targetFramework="net472" /&gt;
    &lt;package id="System.Threading.Tasks.Extensions" version="4.5.1" targetFramework="net472" /&gt;
  &lt;/packages&gt;
  </code></pre>
  
  <p>The test-class</p>
  
  <pre><code>[TestInitialize]
  public void TestInitialize()
  {
      server = new TestServer(new WebHostBuilder().UseStartup&lt;Startup&gt;());
      Client = server.CreateClient();
  }
  
  private HttpClient Client { get; set; }
  
  [TestMethod]
  public async Task GetDatabaseId()
  {
      var response = await Client.GetAsync("api/values");
      ;
  }
  </code></pre>
  
  <p>While debugging the test, the exception "... System.Buffers,..." gets thrown at the line <code>app.UseMvc();</code> in the Startup.cs (Default generated class with zero changes)</p>
  
  <pre><code>// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
  
      app.UseHttpsRedirection();
      app.UseMvc();
  }
  </code></pre>