HubConnection could not be loaded from SignalR Ass

2020-06-29 06:24发布

问题:

I am trying to build a project in Raspberry Pi which communicates with my Azure server via Signalr. I have used SignalR in .NET client side in a mono project while working on a Xamarin project and was successful. For the test purpose, I have written a small block of code.

using System;
using Microsoft.AspNet.SignalR.Client;

namespace testSignalr1
{
  class Program
  {
    static void Main()
     {
        var hubConnection = new HubConnection("******");
        var serverHub = hubConnection.CreateHubProxy("HubTest");
        serverHub.On("broadcastMessage", message => System.Console.WriteLine(message));
        hubConnection.Start().Wait();
        serverHub.Invoke("TestMethod").Wait();
        System.Console.Read();
    }
  }
}

I am compiling this using mcs mono compiler.

sudo mcs test.cs /r: /usr/lib/mono/4.5/Microsoft.AspNet.SignalR.Client.dll

The program actually compiles successfully. But when it is run, I get the following exception

Could not load type 'Microsoft.AspNet.SignalR.Client.HubConnection' from assembly 'Microsoft.AspNet.SignalR.Client'

The Microsoft.AspNet.SignalR.Client.dll I am using is the one in lib folder in this Git Project which demonstrates SingalR in RaspBerry Pi

This seems to be the mono compiled version of SignalR. I cannot figure out where I am going wrong. Thank You in Advance

回答1:

ssh into the raspberry pi and type sudo apt-get install mono-complete this worked for me. I had the same issue when only installed the mono-runtime.