title: System.Net.Http MethodNotFoundException when executing method on .NET Framework 4.7.1 library loaded through Reflection
body: <h2>Setup</h2>
  
  <p>As part of migrating a large VS solution from .Net 4.6 to 4.7.1, I have replaced all packages.config files with "PackageReferences" in each .csproj file and removed the corresponding standard "Reference" tags containing hint paths pointing at the now obsolete "../packages/*" directory. I have also added the <code>&lt;AutoGenerateBindingRedirects&gt;true&lt;/AutoGenerateBindingRedirects&gt;</code> and <code>&lt;RestoreProjectStyle&gt;PackageReference&lt;/RestoreProjectStyle&gt;</code> to each .csproj file.
  This .Net 4.7.1 library has various project references to other .Net 4.7.1 libraries and NuGet packages (some of them targeting .NET Standard versions).</p>
  
  <h2>Execution</h2>
  
  <p>I have a PowerShell script which loads this particular .NET 4.7.1 library through <code>Assembly.LoadFrom("C:\Net471LibraryOutput\Net471Library.dll")</code>, instantiates a class in that assembly through <code>new-object Net471Library.MyClass</code>, and then attempts to execute an async method on that class, but is met with a "MethodNotFoundExcepion" saying that a method defined in a PackageReferenced <strong>NugetPackage</strong> which references System.Net.Http can't be found.</p>
  
  <h2>Observations</h2>
  
  <p>My .NET 4.7.1 library references another 4.7.1 project which references System.Net.Http without a specific version, which VS 2017 resolves to version <em>4.2.0.0</em> which it found at <code>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net471\lib\System.Net.Http.dll</code>
  When I look at the current AppDomain's assemblies after loading this library through reflection, but before executing the command I see my 4.7.1 library's .dll and no <code>System.Net.Http.dll</code> has been loaded. After executing the command I find 2 entries for System.Net.Http have been loaded into the appdomain, each with a distinct version.</p>
  
  <ul>
  <li><code>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll</code> (version <em>4.0.0.0</em>)</li>
  <li><code>C:\Net471LibraryOutput\System.Net.Http.dll</code> (version <em>4.2.0.0</em>)</li>
  </ul>
  
  <p>If I hide System.Net.Http <em>4.2.0.0</em> from VS and rebuild, Net471Library output no longer contains System.Net.Http.dll, and if I repeat those steps without that .dll present, the method executes successfully (no "MethodNotFoundException" on the referenced NuGet package method). If I allow VS to find System.Net.Http <em>4.2.0.0</em>, even if I set all referenced projects to use <em>4.0.0.0</em> specifically (though I can't adjust the PackageReferenced NuGet packages), version <em>4.2.0.0</em> still gets placed in the output and I receive the same error.
  If I try to add a reference to System.Net.Http directly to the library to try to force the output, I get build error CS0433 "The type 'HttpResponseMessage' exists in both 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'"</p>
  
  <p>I have made several attempts to reproduce the issue in a simplified solution with fewer dependencies to narrow down the issue but have been unsuccessful so far.</p>