runtime: Full framework test csproj referencing netstandard csproj using HttpClient fails at runtime

I have a net461 test project that uses a netstandard 1.3 csproj. The netstandard project uses HttpClient.

When I run the tests, some with HTTP gets and some with HTTPS, they fail with this:

System.IO.FileLoadException : Could not load file or assembly 'System.Security.Cryptography.X509Certificates, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at System.Net.Http.WinHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.GetAsync(Uri requestUri, HttpCompletionOption completionOption, CancellationToken cancellationToken)

What can I do about this? There are no warnings or other hints to point me in any direction, and Google searches have left me more confused than ever.

Windows 10 x64 AU Microsoft Visual Studio Professional 2015 Version 14.0.25431.01 Update 3 Microsoft .NET Framework Version 4.6.01586 Microsoft .NET Core Tools (Preview 2) 14.1.20907.0

Don’t know if this matters, dotnet: Version : 1.0.1 Build : cee57bf6c981237d80aa1631cfe83cb9ba329f12

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 32 (26 by maintainers)

Most upvoted comments

@Trolldemorted no worries, glad it was something simple (ish). We’re aiming to improve on a lot of this in the upcoming releases.

sn -t <pathToAssembly> will give you the public key token. sn.exe is in a developer command prompt.

You can also right click the reference in VS and view properties and you’ll see the full strong name.

<assemblyIdentity name="Microsoft.Win32.Primitives"/>

should be

<assemblyIdentity name="Microsoft.Win32.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />