Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

Unable to cast object of type 'Microsoft.AspNetCore.Blazor.Server.Circuits.RemoteJSRuntime' to type 'Microsoft.JSInterop.IJSInProcessRuntime'. #3

Closed
horseyhorsey opened this issue Dec 2, 2018 · 5 comments

Comments

@horseyhorsey
Copy link

I'm getting this right after starting the client. Any ideas?

   at BlazorSignalR.Internal.BlazorHttpConnection.CreateHttpClient() in C:\Users\chand\Projects\BlazorSignalR\src\BlazorSignalR\Internal\BlazorHttpConnection.cs:line 327
   at BlazorSignalR.Internal.BlazorHttpConnection..ctor(BlazorHttpConnectionOptions options, ILoggerFactory loggerFactory) in C:\Users\chand\Projects\BlazorSignalR\src\BlazorSignalR\Internal\BlazorHttpConnection.cs:line 70
   at BlazorSignalR.Internal.BlazorHttpConnectionFactory.ConnectAsync(TransferFormat transferFormat, CancellationToken cancellationToken) in C:\Users\chand\Projects\BlazorSignalR\src\BlazorSignalR\Internal\BlazorHttpConnectionFactory.cs:line 24
@csnewman
Copy link
Owner

csnewman commented Dec 2, 2018

Which version of blazor are you using? And are you using client side or server side blazor? Can I also get a full console output? As some details seem missing

@horseyhorsey
Copy link
Author

  • Blazor 0.7.0
  • Server side, not tested hosted

In Razor page 58 as below is invoking:

await this._connection.StartAsync();
   at Microsoft.AspNetCore.Blazor.Browser.Services.BrowserUriHelper.InitializeState()
   at Microsoft.AspNetCore.Blazor.Services.UriHelperBase.GetBaseUri()
   at BlazorSignalR.Internal.BlazorHttpConnection.CreateHttpClient() in C:\Users\chand\Projects\BlazorSignalR\src\BlazorSignalR\Internal\BlazorHttpConnection.cs:line 327
   at BlazorSignalR.Internal.BlazorHttpConnection..ctor(BlazorHttpConnectionOptions options, ILoggerFactory loggerFactory) in C:\Users\chand\Projects\BlazorSignalR\src\BlazorSignalR\Internal\BlazorHttpConnection.cs:line 70
   at BlazorSignalR.Internal.BlazorHttpConnectionFactory.ConnectAsync(TransferFormat transferFormat, CancellationToken cancellationToken) in C:\Users\chand\Projects\BlazorSignalR\src\BlazorSignalR\Internal\BlazorHttpConnectionFactory.cs:line 24
   at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync(CancellationToken cancellationToken)
   at RetroDbBlaze.App.Pages.Index.OnInitAsync() in C:\Users\funktub\Documents\Visual Studio 2017\Projects\RetroDb\src\User\RetroDbBlaze\RetroDbBlaze.App\Pages\Index.cshtml:line 58

@csnewman
Copy link
Owner

csnewman commented Dec 2, 2018

Ah, the issue is quite simple, this project assumes we are running inside the browser, not server side. It will be a simple fix.

However, I question why you are trying to use this library to use SignalR, as this will proxy all requests from the server, to the browser, and then out to the internet? If you are using Server Side Blazor, then you probably just want the standard SignalR client (or both if you use client side and server side, and then just detect at runtime which to use), as this will open the SignalR connections directly from the server out to the internet?

@horseyhorsey
Copy link
Author

I see. I don't know the JS client at all :) and think I was trying to avoid it. I just wanted a tiny bit of polling and decided to use SignalR. I just assumed this was a wrapper over the client.

Thanks

@csnewman
Copy link
Owner

Using BlazorSignalR with Razor Components (Aka server side blazor) is being implemented via #12

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants