Arash
Arash

Reputation: 4260

Weired exception in signalR related to type System.Net.Http.WebRequestHandler

Created a server signalR application successfully and I am able to view the created JavaScript code template by navigating to http://localhost:11914/signalr/hubs.

The client application is a .NET 4.6.2 web api created with the recent template by Visual Studio 2017 latest RC. When I execute the code below:

    var hubConnection = new HubConnection("http://localhost:11914");
    var hubProxy = hubConnection.CreateHubProxy("cache");
    hubProxy.On<CachedObjectInfo>("sendUpdateNotification", cachedObject => RefreshMemory(cachedObject));
    await hubConnection.Start();

I receive the exception below in when hitting await hubConnection.Start();

type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security accessibility of the base type or be less accessible.'

The client singalR application leverages Microsoft.AspNet.SignalR.Client version 2.2.1 package.

I have no idea why I should be receiving such an exception and I could not find any solutions. What's the root cause and how to mitigate it?

Upvotes: 0

Views: 316

Answers (1)

Drew
Drew

Reputation: 1337

I believe it's an issue with the System.Net.Http package version. More specifically, if you have v4.1.1 - v4.3.0 installed for the project you run then you will run into this issue when you target .NET 4.6.1 or 4.6.2. See this thread for more details. To fix this issue, they released a new package, System.Net.Http 4.3.1, that should get rid of the error.

Upvotes: 1

Related Questions