Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR not working in ASP .Net 5 RC-1

I can't seem to get SignalR 3 working on ASP .Net 5 RC-1 upgrading from Beta8. I tried the latest RC1 package for SignalR but had the following problem. I tried the "Microsoft.AspNet.SignalR.Server": "3.0.0-rc1-15810" package

services.AddSignalR();

is causing the following error:

The type 'IServiceCollection' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

and app.UseSignalR();

is causing this one:

The type 'IApplicationBuilder' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.AspNet.Http.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

When I switch to the "Microsoft.AspNet.SignalR.Server": "3.0.0-rc2-15909" package I get a runtime error:

An exception of type 'System.TypeLoadException' occurred in mscorlib.dll but was not handled in user code

Additional information: Could not load type 'Microsoft.AspNet.Http.RequestDelegate' from assembly 'Microsoft.AspNet.Http.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

like image 366
Tjaart Avatar asked Nov 23 '15 07:11

Tjaart


People also ask

Does SignalR need SSL?

If your SignalR application transmits sensitive information between the client and server, use SSL for the transport.

What causes SignalR to disconnect?

If a server does not become available within the disconnect timeout period, the SignalR connection ends. In this scenario, the Closed event ( disconnected in JavaScript clients) is raised on the client but OnDisconnected is never called on the server.

Does SignalR require WebSockets?

ASP.NET Core SignalR is a library that simplifies adding real-time web functionality to apps. It uses WebSockets whenever possible. For most applications, we recommend SignalR rather than raw WebSockets.


1 Answers

I've just tested this, and it looks like a reference to the aspnetmaster myget feed is required, even though this is not mentioned in the installation docs.

Prior to including aspnetmaster I could only resolve Microsoft.AspNet.SignalR.Server 3.0.0-rc1-15810 either directly or by specifying rc1-*, which does not build against rc1-final. Including aspnetmaster gives access to rc1-final.

If you're using Visual Studio 2015, go to Tools > Options > Nuget Package Manager > Package Sources and add a new feed called whatever you like but with source set to https://www.myget.org/F/aspnetmaster/api/v3/index.json.

If you're not using VS2015, or you don't want to edit your machine-wide config, add/edit NuGet.config in your solution root directory to include a package source as follows;

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="aspnetmaster" value="https://www.myget.org/F/aspnetmaster/api/v3/index.json" />
  </packageSources>
</configuration>
like image 55
Stafford Williams Avatar answered Sep 21 '22 16:09

Stafford Williams