Signal R with vNext

I find it difficult to use SignalR in a vNext project (epmty template).

First I added a SignalR.Server dependency to my project.json file and now it looks like this:

{ "webroot": ".", "dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-beta3", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.AspNet.StaticFiles": "1.0.0-*", "Microsoft.AspNet.SignalR.Server": "3.0.0-*", "Serilog": "1.4.113.0" }, "commands": { "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5002" }, "frameworks": { "dnx451": { "dependencies": { "Microsoft.Framework.Logging.Serilog": "1.0.0-*" } }, "dnxcore50": { } } } 

And then I wanted to display SignalR in my Startup.cs (since I found somwhere on git)

  public void ConfigureServices(IServiceCollection services) { services.AddSignalR(options => { options.Hubs.EnableDetailedErrors = true; }); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { #if DNX451 string OutputTemplate = "{SourceContext} {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"; var serilog = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.RollingFile(@".\SignalR-Log-{Date}.txt", outputTemplate: OutputTemplate); loggerFactory.AddSerilog(serilog); #endif app.UseFileServer(); app.UseSignalR<RawConnection>("/raw-connection"); app.UseSignalR(); } 

but when I add at the top:

 using Microsoft.AspNet.SignalR; 

I get an error:

The type or namespace name 'SignalR' does not exist in the namespace> 'Microsoft.AspNet' (do you miss the assembly reference?) VersaWeb.ASP.NET> 5.0 c: \ Users \ Jakub \ documents \ visual studio> 2015 \ Projects \ VersaWeb \ SRC \ VersaWeb \ Startup.cs

And I'm stuck right now.


EDIT:

The problem should be the .json project, because when I copied the file from the music store, the problem disappeared.

Here is my current project.json (maybe some of the dependencies are not needed, so I will still test it)

 { "authors": [ "author" ], "description": "your description here", "version": "1.0.0", "compilationOptions": { "warningsAsErrors": true, "define": [ "DEMO", "TESTING" ] }, "code": [ "**/*.cs" ], "bundleExclude": "*.cmd", "webroot": "wwwroot", "dependencies": { "EntityFramework.SqlServer": "7.0.0-beta3", "EntityFramework.InMemory": "7.0.0-beta3", // For Mono. "Kestrel": "1.0.0-beta3", "Microsoft.AspNet.Diagnostics": "1.0.0-beta3", "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta3", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta3", "Microsoft.AspNet.Mvc": "6.0.0-beta3", "Microsoft.AspNet.Security.OpenIdConnect": "1.0.0-beta3", "Microsoft.AspNet.Server.IIS": "1.0.0-beta3", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta3", "Microsoft.AspNet.SignalR.Server": "3.0.0-beta3", "Microsoft.AspNet.StaticFiles": "1.0.0-beta3", "Microsoft.Framework.Cache.Memory": "1.0.0-beta3", "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta3", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta3", "Microsoft.Framework.Logging.Console": "1.0.0-beta3" }, "commands": { "gen": "Microsoft.Framework.CodeGeneration", "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004", "run": "run server.urls=http://localhost:5003", "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002" }, "frameworks": { "aspnet50": { }, "aspnetcore50": { } } } 
+6
source share
2 answers

Checkout the sample MusicStore that uses SignalR. I also use SignalR in my vnext project (albeit with kre and not with new dnx stuff), so it is definitely doable.

+4
source

Looking at the original project.json , you were probably trying to target dnx451 , but were working against the wrong .NET development environment.

The main thing that I found when working with this vNext material is that all your links should be at the same beta3 / beta4 / beta5 level, and .NET runtime should match ( frameworks in project.json ). I believe beta3 used aspnet50 , and since beta4 rename it now dnx451 .

At the command line, there is a dnvm list and see what is installed and what is set in the default alias, because this is what Visual Studio will use when the application starts (if you do not override the file in the global.json solution).

+2
source

Source: https://habr.com/ru/post/985669/


All Articles