Aspnetcore: Unable to use SignalR HubConnectionBuilder.WithUrl and HttpConnectionOptions in Core 3.0

Created on 16 Dec 2018  路  6Comments  路  Source: dotnet/aspnetcore

Using latest Core 3.0

I'm trying:

    hubConnection = new HubConnectionBuilder().WithUrl("http://localhost:5000/hubs/agenthub", options => options.Cookies.Add(myCookie)).Build();

I get:

Error CS0012 The type 'HttpTransportType' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.AspNetCore.Http.Connections.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. VoyAdminAgent

If I try to install package Microsoft.AspNetCore.Http.Connections.Common, the latest nuget version is 1.1.0 and I then get:

Error CS1705 Assembly 'Microsoft.AspNetCore.SignalR.Client' with identity 'Microsoft.AspNetCore.SignalR.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' uses 'Microsoft.AspNetCore.Http.Connections.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.AspNetCore.Http.Connections.Common' with identity 'Microsoft.AspNetCore.Http.Connections.Common, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

Any help ?

PM> get-package
Microsoft.EntityFrameworkCore       {3.0.0-preview.18572.1}                  VoyAdminAgent                                                                       
Microsoft.EntityFrameworkCore.Sq... {3.0.0-preview.18572.1}                  VoyAdminAgent                                                                       
Microsoft.AspNetCore.SignalR.Client {3.0.0-preview-18579-0056}               VoyAdminAgent                                                                       
Microsoft.NETCore.App               {3.0.0-preview-27122-01}                 VoyAdminAgent                                                                       
area-signalr

Most helpful comment

I'm guessing you're referencing nuget package "Microsoft.AspNetCore.SignalR.Client.Core" instead of "Microsoft.AspNetCore.SignalR.Client"

All 6 comments

This has been fixed in master. If you'd like to use the MyGet feed, you could grab the latest bits and try it out.

I have the same issue with 3.0.0-preview5.

Microsoft.EntityFrameworkCore.Sq... {3.0.0-preview5.19227.1}                 BoincManagerWeb                                                                                                                       
Microsoft.EntityFrameworkCore.De... {3.0.0-preview5.19227.1}                 BoincManagerWeb                                                                                                                       
Microsoft.NETCore.Platforms         {3.0.0-preview5.19224.8}                 BoincManagerWeb                                                                                                                       
Microsoft.Extensions.Logging.Debug  {3.0.0-preview5.19227.9}                 BoincManagerWeb                                                                                                                       
Microsoft.VisualStudio.Web.CodeG... {3.0.0-preview5-19264-04}                BoincManagerWeb                                                                                                                       
Microsoft.EntityFrameworkCore.Tools {3.0.0-preview5.19227.1}                 BoincManagerWeb                                                                                                                       
Microsoft.AspNetCore.Mvc.Newtons... {3.0.0-preview5-19227-01}                BoincManagerWeb                                                                                                                       
Microsoft.AspNetCore.SignalR.Cli... {3.0.0-preview5-19227-01}                BoincManagerWeb                                                                                                                       
Microsoft.VisualStudio.Azure.Con... {1.4.10}                                 BoincManagerWeb  

The code:
var connection = new HubConnectionBuilder().WithUrl("http://localhost:53353/ChatHub").Build();

Error message:
Error CS1061 'HubConnectionBuilder' does not contain a definition for 'WithUrl' and no accessible extension method 'WithUrl' accepting a first argument of type 'HubConnectionBuilder' could be found (are you missing a using directive or an assembly reference?)

I'm guessing you're referencing nuget package "Microsoft.AspNetCore.SignalR.Client.Core" instead of "Microsoft.AspNetCore.SignalR.Client"

I used this tutorial and it says Microsoft.AspNetCore.SignalR.Client.

Do you have a sample app?

If it's boinc-manager/BoincManagerWeb then you're referencing "Microsoft.AspNetCore.SignalR.Client.Core" in it which wont provide the WithUrl extension method.

I see.
I moved on and chose another way, so I can't provide a sample app.
Thanks anyway.

Was this page helpful?
0 / 5 - 0 ratings