Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Startup: services.AddRemoting defaults to ServerRemotingExtensions.AddRemoting, causing runtime exception #22

Open
weebs opened this Issue Jan 23, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@weebs
Copy link

weebs commented Jan 23, 2019

I ran into this issue today while trying to add remoting to the Bolero client side project. It seems that when I call services.AddRemoting(), it calls one of the ServerRemotingExtensions methods, and produces the following runtime error

System.ArgumentException: 'Cannot instantiate implementation type 'Bolero.Remoting.IRemoteHandler' for service type 'Bolero.Remoting.IRemoteHandler'.'

Sample code:

namespace RemoteTest.Client

open Microsoft.AspNetCore.Blazor.Builder
open Microsoft.AspNetCore.Blazor.Hosting
open Microsoft.Extensions.DependencyInjection
open Bolero.Remoting

type Startup() =

    member __.ConfigureServices(services: IServiceCollection) =
        // Causes a runtime error
        services.AddRemoting() |> ignore
        // Works as expected
        ClientRemotingExtensions.AddRemoting(services) |> ignore

    member __.Configure(app: IBlazorApplicationBuilder) =
        app.AddComponent<Main.MyApp>("#main")

module Program =

    [<EntryPoint>]
    let Main args =
        BlazorWebAssemblyHost.CreateDefaultBuilder()
            .UseBlazorStartup<Startup>()
            .Build()
            .Run()
        0

@weebs weebs changed the title Client Startup: services.AddRemoting defaults to ServerRemotingExtensions.AddRemoting Client Startup: services.AddRemoting defaults to ServerRemotingExtensions.AddRemoting, causing runtime exception Jan 23, 2019

@Tarmil

This comment has been minimized.

Copy link
Member

Tarmil commented Jan 23, 2019

Hmm, that's annoying indeed. It's strange that it defaults to the version that has a type parameter when you don't give one. Looks like we might have to either rename the methods (eg AddClientRemoting / AddServerRemoting) or move one of the extension classes to a submodule (eg open Bolero.Remoting.Server).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.