Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Trying to start a SignalR connection from an ASP.NET Core action call gives TypeLoadException

$
0
0

The setup I'm trying to accomplish is this: I have a signalR server that supports 2 types of clients - one type that supplies data and another that receives data. When a "receiver" type client chooses one of the "sender" type clients to monitor, the SignalR server makes a call to the "sender" client to open a connection. The "sender" client is an ASP.NET Core instance running as a Windows Service. The POST request calls a service that starts a timer and tries to open a SignalR connection as a client. The POST request is going through as expected and it calls the service properly. When the service tries to open the SignalR connection, though, I get: System.TypeLoadException in SignalR.Client.dll (Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security accessibility of the base type or be less accessible).

The action method in the controller looks like this:

[HttpPost]
public IActionResult StartUpdate()
{
    _updateDriver.StartTiming();

    return Ok("Timing has started");
}

And the method in the service looks like this:

public void StartTiming()
{
    if (!_isTiming)
    {
        try
        {
            _hubProxy = _hubConnection.CreateHubProxy("RemoteDataServerHub");
            _hubConnection.Start().Wait();
            _hubProxy.Invoke("JoinGroup", "Sender").Wait();
            _timer.Start();
            _isTiming = true;
        }
        catch (Exception ex)
        {
            Debug.Print(ex.Message);
            _isTiming = false;
        }
    }
}


The exception is thrown on the _hubConnection.Start().Wait() line. Does anyone have any idea what's going on here? I'm not very experienced in web applications or ASP.NET Core or SignalR. I may be biting off a bit more than I can chew here. But if anyone can point me in the right direction, it would be much appreciated!

Thanks!


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>