SignalR icon indicating copy to clipboard operation
SignalR copied to clipboard

Method not found: 'System.Security.Cryptography.X509Certificates.X509CertificateCollection System.Net.Http.HttpClientHandler.get_ClientCertificates()'.

Open screaney opened this issue 8 years ago • 8 comments

  • Versions of Server-Side NuGet Packages: v1.0.1
  • Are you using the C# client or the JavaScript client: C#
  • The Server you are using (Kestrel/HttpSysServer/IIS/IIS Express/Azure Web App/etc.): IIS
  • The Operating System on the Server (Windows/Linux/macOS): Server 2008 R2
  • The Operating System on the Client (Windows/Linux/macOS): Windows
  • The Browser on the client, if using the JavaScript client (IE/Chrome/Edge/Firefox/etc.): Any

Running MVC Asp.Net web application connecting to ASPNET Core SignalR service. When calling HubConnection.StartAsync(), critical exception occurs on the server only, doesn't happen when I run locally on IIS Express or using similar code in Linqpad.

Connection = new HubConnectionBuilder().WithUrl("[serverurl]").Build();
await Connection.StartAsync();

Exception: System.MissingMethodException

Message: Method not found: 'System.Security.Cryptography.X509Certificates.X509CertificateCollection System.Net.Http.HttpClientHandler.get_ClientCertificates()'.

Relevant Stack Trace (some removed for clarity):


StackTrace:    at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.CreateHttpClient()
   at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection..ctor(HttpConnectionOptions httpConnectionOptions, ILoggerFactory loggerFactory)
   at Microsoft.AspNetCore.SignalR.Client.HttpConnectionFactory.<ConnectAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.Client.HubConnection.<StartAsyncCore>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.SignalR.Client.HubConnection.<StartAsync>d__24.MoveNext()

screaney avatar Jun 20 '18 20:06 screaney

What framework are you running against? .NET Core or .NET Framework? And what version is installed?

BrennanConroy avatar Jun 20 '18 21:06 BrennanConroy

Exception occurs in .Net 4.6.1 MVC web application using Microsoft.AspNetCore.SignalR.Client 1.0.1

screaney avatar Jun 20 '18 21:06 screaney

Unfortunately there are a small number of API's that are not available to .NET 4.6.1 when using libraries targeting netstandard2.0. It looks like HttpClientHandler.get_ClientCertificates might be one of those. As a workaround you can install 4.7.1 or later or retarget to .NET Core

@karelz does that sound accurate?

BrennanConroy avatar Jun 20 '18 21:06 BrennanConroy

I am not sure if this is one of them. I would expect rather PlatformNotSupported exception, but not MissingMethodException. I think .NET Standard tries to bridge the gap - see apisof.net. @weshaggard do you have more insights?

karelz avatar Jun 20 '18 23:06 karelz

apisof.net says .NET Framework 4.7.1, however netstandard2.0 supports .NET Framework 4.6.1 so if you run against 4.6.1 then ...?

BrennanConroy avatar Jun 20 '18 23:06 BrennanConroy

Facades can do magic :)

karelz avatar Jun 20 '18 23:06 karelz

This is one of those few APIs that will fail with MissingMethodException on .NET 4.6.1, you can see the list here https://github.com/dotnet/standard/blob/master/netstandard/src/ApiCompatBaseline.net461.txt#L19.

weshaggard avatar Jun 20 '18 23:06 weshaggard

Ok, so it sounds like the only resolution here is for @screaney to update the application to run on .NET Framework 4.7.1. I'm going to close this issue as there isn't really anything SignalR can do if the API is simply missing on 4.6.1.

analogrelay avatar Jun 20 '18 23:06 analogrelay