Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Using app.UseSignalR causes a System.MissingMethodException at Startup #690

Closed
ssougnez opened this issue Aug 4, 2017 · 13 comments
Closed

Comments

@ssougnez
Copy link

ssougnez commented Aug 4, 2017

Hi,

I'm trying to host a simple hub in my ASP.NET Core 2.0 Application. Here are the relevant part of my code:

public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .UseDefaultServiceProvider(options => options.ValidateScopes = false)
        .Build();
public void ConfigureServices(IServiceCollection services)
{
    services.AddSignalR();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseWebSockets();

    app.UseSignalR(options =>
    {
        options.MapHub<ChatHub>("chat");
    });
}
public class ChatHub : Hub
{
}

When I try to run this application, I get the error:

Method not found: 'System.Collections.Generic.Dictionary`2<System.String,System.Object> Microsoft.Extensions.Configuration.IConfigurationBuilder.get_Properties()'.

With the following stack trace:

at Microsoft.Extensions.Configuration.FileConfigurationExtensions.SetFileProvider(IConfigurationBuilder builder, IFileProvider fileProvider)
at Microsoft.Extensions.Configuration.FileConfigurationExtensions.SetBasePath(IConfigurationBuilder builder, String basePath)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at RobotWar.Program.BuildWebHost(String[] args) in C:\XXX\Program.cs:line 18

The stack trace seems to indicate that it's not directly coming from SignalR but when I remove app.UseSignalR(...), I don't have the issue anymore.

I'm using the version 1.0.0-alpha1-26462.

@davidfowl
Copy link
Member

They are incompatible, you can wait for ASP.NET Core 2.0 to be released or update to a newer ci build.

@ssougnez
Copy link
Author

ssougnez commented Aug 4, 2017

Ow okay, didn't know that.

I'll see how I can update my version of ASP.NET Core 2.0 with the CI build :-D

Thanks

@mclasson
Copy link

mclasson commented Aug 4, 2017

@davidfowl When I upgrade to the latest aspnetcore and signalr
"Microsoft.AspNetCore.All" Version="2.1.0-preview1-26462"
"Microsoft.AspNetCore.SignalR" Version="1.0.0-alpha1-26462"
I get this error:
Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

@ssougnez
Copy link
Author

ssougnez commented Aug 4, 2017

Yep, got the exact same issue, I'm trying to figure it out right now xD

The least we can say is that trying to use the latest version of SignalR is not a piece of cake :-D (no pun intended ;-))

@davidfowl
Copy link
Member

You need to also get the latest version of .NET Core. Update everything together.

@mclasson
Copy link

mclasson commented Aug 4, 2017

There is newer one than 2.0.0-preview2-006497? Can't find it.

@ssougnez
Copy link
Author

ssougnez commented Aug 4, 2017

Yay, I installed ASP.NET Core 2.1.0 and indeed, it solves the issue. mclasson, you can find the binaries here : https://github.com/dotnet/cli

Just another question, I installed the "signalr-client 0.0.17" npm package and I see that there is a sample in there. Is it still compatible with the current version of SignalR ?

Thanks

@moozzyk
Copy link
Contributor

moozzyk commented Aug 4, 2017

@ssougnez - where did you install it from? It does not seem to be correct. The latest is 0.1.0-alpha1-26553.

@ssougnez
Copy link
Author

ssougnez commented Aug 4, 2017

Indeed, sorry, in the meantime, I found the issue. There is actually a "signalr-client" package on the default npm registry, I didn't see that I had to install the one from MyGet. I succedded installing it and so far, it seems to work pretty well.

Thanks

@zhimaqiao1
Copy link

dude i had the same issue struggled for 4 days mixing and matching packages but then Marcus Classon came to my rescue and directed me here. Thanks Marcus. David Fowler also answered my emails .. he says

It's because SignalR is building against the latest ASP.NET Core ci builds. The way to make it work would be to update everything:

The key is to align the build numbers. SignalR is currently 1.0.0-alpha-{buildnumber} and ASP.NET Core is 2.0.0-rtm-{buildnumber}.

Another option would be to wait on the 2.0.0 release.

But now im having another problem.
getting it to run in a docker container.. I could have sworn i got it to run the first time but now its not going... heres my issue inside the docker container...


You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.

realpath(): Invalid argument
realpath(): Invalid argument
realpath(): Invalid argument
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.0.0' was not found.

  • Check application dependencies and target a framework version installed at:
    /
  • Alternatively, install the framework version '2.0.0'.
    The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
    The program '[52] dotnet' has exited with code 131 (0x83).
    The program '' has exited with code 131 (0x83).

@zhimaqiao1
Copy link

docker image
microsoft/aspnetcore:2.0

@muratg
Copy link

muratg commented Aug 18, 2017

Wrong dependencies.

@muratg muratg closed this as completed Aug 18, 2017
@brolaugh
Copy link

Had this same issue after the release of .NET Core 2.0. Took me a while to realize that I was running on a pre release version of 2.0 (which I had downloaded a while back). Just downloading and installing the final release fixed it for me.

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

7 participants