Signalr Core for ASP.net core 2.0 does not work no matter what I try

trying to follow the video microsoft w / Mikael Mengistu, Jon Galloway, Maria Naggaga.

https://channel9.msdn.com/Shows/Code-Conversations/Introduction-to-SignalR-Core-with-Mikael-Mengistu

0. this is what my car looks like. dotnet --version 2.0.0-preview2-006497 Microsoft.NET Core Shared Framework Host Runtime Version: 2.0.0-preview2-25407-01 Visual Studio 2017 15.3 MVC docker-enabled web project

here is the repo code of my attempt. github.com/zhimaqiao1/SRcoreWorking signalr-client I had to edit myself to get something at least halfway.

  • started with the mvc vanilla template which targets netcoreapp2.0 and PackageReference Microsoft.AspNetCore.All "Version =" 2.0.0-preview2-final "

  • tried to add signalr core nuget packages from dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json (this is the nuget report seen in the video.) Microsoft.AspNetCore.SignalR Version = 1.0.0-alpha1 -26462

  • Nuget's user interface in visual studio warns me that it should update some things to 2.1.0-Preview1-26462

.... without adding a line of code I just f5 and get a runtime error (and not a build error)

in line

  public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .Build();

the error is 

    System.MissingMethodException occurred HResult=0x80131513
    Message=Method not found: 
    System.IDisposable.Microsoft.Extensions.Options.IOptionsMonitor`1.OnChange(System.Action`1<!0>)'
    StackTrace:
    Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider..ctor(IOptionsMonitor`1 options)
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
  1. I take the theoretical assumption that some extension method coming from signalr and applied to something in aspnet core 2.0 is not looking for this thing that does not exist. Therefore, I am adding another signalr package just for this. Microsoft.AspNetCore.SignalR.Http Version = 1.0.0-alpha1-26462

when i press f5 i get another error! (woohoo makes progress)

   System.MissingMethodException occurred
  HResult=0x80131513
  Message=Method not found: 'System.Collections.Generic.Dictionary`2<System.String,System.Object> Microsoft.Extensions.Configuration.IConfigurationBuilder.get_Properties()'.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

5

I continue to add signalr packages hoping something will work
Microsoft.AspNetCore.SignalR" Version="1.0.0-alpha1-26462" 
Microsoft.AspNetCore.SignalR.Client" Version="1.0.0-alpha1-26462" 
Microsoft.AspNetCore.SignalR.Common" Version="1.0.0-alpha1-26462"
Microsoft.AspNetCore.SignalR.Http" Version="1.0.0-alpha1-26462"
Microsoft.AspNetCore.SignalR.Redis" Version="1.0.0-alpha1-26462"



still i get the 
   System.MissingMethodException occurred
  HResult=0x80131513
  Message=Method not found: 'System.Collections.Generic.Dictionary`2<System.String,System.Object> Microsoft.Extensions.Configuration.IConfigurationBuilder.get_Properties()'.

6.

, signalr dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json

PackageReference Microsoft.AspNetCore.All "Version =" 2.0.0-preview2-final " 2.1.0-Preview1-26462

Microsoft.AspNetCore.All 2.1.0-Preview1-26462, ... dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json

signalr - nuget . \nuget.exe locals all -clear

f5 (, mvc aspnetcore 2.0, )

.....

System.IO.FileLoadException HResult = 0x80131040 = 'System.Diagnostics.DiagnosticSource, Version = 4.0.2.1, Culture = neutral, PublicKeyToken = cc7b13ffcd2ddd51'. . ( HRESULT: 0x80131040) = :   Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException & HostStartupErrors)   Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()   WebApplication1.Program.BuildWebHost(String [] args) D:\org\projects\fogbridge3\ActorModelDojo\src\Solution2\WebApplication1\Program.cs: 21   WebApplication1.Program.Main(String [] args) D:\org\projects\fogbridge3\ActorModelDojo\src\Solution2\WebApplication1\Program.cs: 17

  1. , , Microsoft.AspNetCore.All "Version =" 2.1.0-preview1-26462 "

, Microsoft.AspNetCore.Hosting, System.Diagnostics.DiagnosticSource , . downlevel System.Diagnostics.DiagnosticSource 4.0.2.1 dll . , C:\Users\gracie.nuget\packages\system.diagnostics.diagnosticsource C:\Users\gracie.nuget\packages\system.diagnostics.diagnosticsource\4.0.0\lib net46 netstandard1.1 netstandard1.3 -net45 + Win8 + wpa81

... .

     Dependency "System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
         Could not resolve this reference. Could not locate the assembly "System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
             For SearchPath "C:\Users\gracie\.nuget\packages\microsoft.aspnetcore.hosting\2.1.0-preview1-26462\lib\netstandard2.0".
             Considered "C:\Users\gracie\.nuget\packages\microsoft.aspnetcore.hosting\2.1.0-preview1-26462\lib\netstandard2.0\System.Diagnostics.DiagnosticSource.winmd", but it didn't exist.
             Considered "C:\Users\gracie\.nuget\packages\microsoft.aspnetcore.hosting\2.1.0-preview1-26462\lib\netstandard2.0\System.Diagnostics.DiagnosticSource.dll", but it didn't exist.
             Considered "C:\Users\gracie\.nuget\packages\microsoft.aspnetcore.hosting\2.1.0-preview1-26462\lib\netstandard2.0\System.Diagnostics.DiagnosticSource.exe", but it didn't exist.

C:\Users\gracie.nuget\packages\system.diagnostics.diagnosticsource\4.0.0\lib\netstandard1.3 C:\Users\gracie.nuget\packages\microsoft.aspnetcore.hosting\2.1.0-preview1-26462\lib\netstandard2.0 \ .

csproj PackageReference Include = "Microsoft.AspNetCore.All" = "2.1.0-preview1-26462" PackageReference Include = "System.Diagnostics.DiagnosticSource" = "4.0.2.1"

8 , ... NU1605 : System.Diagnostics.DiagnosticSource 4.4.1 4.0.2.1. , .  WebApplication1 ( >= 1.0.0) → Microsoft.AspNetCore.All( >= 2.1.0-preview1-26462) → Microsoft.AspNetCore.Diagnostics( >= 2.1.0-preview1-26462) → System.Diagnostics. ( >= 4.4.1)  WebApplication1 ( >= 1.0.0) → System.Diagnostics.DiagnosticSource( >= 4.3.0) WebApplication1 D:\org\projects\fogbridge3\ActorModelDojo\src\Solution2\WebApplication1\WebApplication1.csproj 1

.

, .     MVC, .   , .

   public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .Build();

aspnetcore 1.1 - .

, , signalr ( ).

... !!!!!!!

, , , .

PackageReference Include = "Microsoft.AspNetCore.All" = "2.0.0-preview2-final" PackageReference Include = "Microsoft.AspNetCore.SignalR" = "1.0.0-preview2-25794" PackageReference Include = "Microsoft.AspNetCore.SignalR.Http" = "1.0.0-preview2-25794"

signalr ( ) aspnetcore-release myget dotnet.myget.org/F/aspnetcore-release/api/v3/index.json

- MVC signalr.

public void ConfigureServices ( IServiceCollection)   {

    //services.AddMvc();
    services.AddSockets();
    //services.AddSocketsCore();
    services.AddSignalRCore( );
}

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseStaticFiles();

            app.UseSignalR(routes =>
            {
                routes.MapHub<Chat>("chat");
            });

}

public class Chat: Hub {

public override async Task OnConnectedAsync()
{
    await Clients.Client(Context.ConnectionId).InvokeAsync("connectionmade", "connection made dude");

    await base.OnConnectedAsync();
}

public async Task Send(string message)
{
    await Clients.All.InvokeAsync("Send",  message);
}

}

installed my client into node_modules 
npm install signalr-client --registry dotnet.myget.org/F/aspnetcore-ci-dev/npm --save-dev

 copied the signalr-client.js into 
/lib/signalr-client/dist/browser/signalr-client.js

chat.html wwww ....

  let transportType = signalR.TransportType [getParameterByName ('transport')] || signalR.TransportType.WebSockets;

let http = new signalR.HttpConnection(`http://${document.location.host}/chat`, { transport: transportType });
let connection = new signalR.HubConnection(http);

nuget

.\nuget.exe locals all -clear

PackageReference Include = "Microsoft.AspNetCore.All" = "2.0.0-preview2-final" PackageReference Include = "Microsoft.AspNetCore.SignalR" = "1.0.0-preview2-25794" PackageReference Include = "Microsoft.AspNetCore.SignalR.Http" = "1.0.0-preview2-25794"

f5. !!!! SyntaxError: c JSON 0

signalr- 171 ..... let negotiatePayload = yield this.httpClient.options(this.url); negotiatePayload - connectionid f35c2377-5477-413b-a861-e41c57ee0e92

172 - ...... let negotiateResponse = JSON.parse(negotiatePayload); . SyntaxError: JSON 1

, -, . , TypeError: availableTransports undefined

- .net!!!!!! ... WebSocket ws://localhost: 55592/chat? Id = f7c96a55-0266-452d-b071-3b04b7794aad signalr-client.js: 575: 21 ( WebSockets): { "invocationId": "1", "type": 1, "target": "connectionmade", "nonBlocking": true, "arguments": [ "connection made dude" ]}

signalr-....

startInternal() {
    return __awaiter(this, void 0, void 0, function* () {
        try {
            let negotiatePayload = yield this.httpClient.options(this.url);
            //let negotiateResponse = JSON.parse(negotiatePayload);
            let negotiateResponse = negotiatePayload;
            //this.connectionId = negotiateResponse.connectionId;
            this.connectionId = negotiateResponse;
            // the user tries to stop the the connection when it is being started
            if (this.connectionState == ConnectionState.Disconnected) {
                return;
            }
            this.url += (this.url.indexOf("?") == -1 ? "?" : "&") + `id=${this.connectionId}`;
            //this.transport = this.createTransport(this.options.transport, negotiateResponse.availableTransports);

            this.transport = new Transports_1.WebSocketTransport();


            this.transport.onDataReceived = this.onDataReceived;
            this.transport.onClosed = e => this.stopConnection(true, e);
            yield this.transport.connect(this.url);

, , : : Websocket : 1011()

- .....

        function parseMessage(input, position) {
            var offset = position;
            // Read the length
            var [lenStr, offset] = splitAt(input, ":", offset);
            // parseInt is too leniant, we need a strict check to see if the string is an int
            if (!LengthRegex.test(lenStr)) {
                throw new Error(`Invalid length: '${lenStr}'`);    <------ throws this error..
where..
input = "{"invocationId":"5","type":1,"target":"connectionmade","nonBlocking":true,"arguments":["connection made dude"]}    

, !!! signalr-???

, signalr   dotnet.myget.org/F/aspnetcore-release/api/v3/index.json   PackageReference Include = "Microsoft.AspNetCore.SignalR" = "1.0.0-preview2-25794"   PackageReference Include = "Microsoft.AspNetCore.SignalR.Http" = "1.0.0-preview2-25794"

doesnt seem to have a client for me.
i tried npm install signalr-client --registry https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json --save-dev
but that doesnt work so i went with the original one from the video
npm install signalr-client --registry dotnet.myget.org/F/aspnetcore-ci-dev/npm --save-dev

i also tried the one from aspnet core github site https://github.com/aspnet/SignalR

, https://github.com/aspnet/SignalR . .

-, , . - ​​asp.net signalr linux. - , , asp.net, Linux. Signalr .NET.

.

sdk..... dotnet -- 2.0.0-preview2-006497

Microsoft.NET Core Shared Framework : 2.0.0-preview2-25407-01

Visual Studio 2017 15.3 - MVC Docker

+1
3
+2

, 4 ...

f5 mvc visual studio 2017 15.3

  public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .Build();

,

System.MissingMethodException HResult = 0x80131513
= : 'System.IDisposable.Microsoft.Extensions.Options.IOptionsMonitor 1.OnChange(System.Action 1). = StackTrace: at Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider..ctor(IOptionsMonitor`1 ) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider)

System.MissingMethodException HResult = 0x80131513
= : "System.Collections.Generic.Dictionary`2 Microsoft.Extensions.Configuration.IConfigurationBuilder.get_Properties()".

System.IO.FileLoadException       HResult = 0x80131040       Message = . System.Diagnostics.DiagnosticSource, Version = 4.0.2.1, = , PublicKeyToken = cc7b13ffcd2ddd51 '. . ( HRESULT: 0x80131040)        =        :         Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException & hostingStartupErrors)         Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()         WebApplication1.Program.BuildWebHost(String [] args) D:\org\projects\fogbridge3\ActorModelDojo\src\Solution2\WebApplication1\Program.cs: 21         WebApplication1.Program.Main(String [] args) D:\org\projects\fogbridge3\ActorModelDojo\src\Solution2\WebApplication1\Program.cs: 17

signalr!!!

signalr asp.net, , - ... signalr.

, , mvc:

aspnetcore-release ( ) https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json PackageReference Include = "Microsoft.AspNetCore.SignalR" = "1.0.0-preview2-25794" PackageReference Include = "Microsoft.AspNetCore.SignalR.Http" Version = "1.0.0-preview2-25794"

nuget.org(preerelease) https://api.nuget.org/v3/index.jsonPackageReference Include = "Microsoft.AspNetCore.All" Version = "2.0.0-preview2-"

, ,

npm install signalr-client -- dotnet.myget.org/F/aspnetcore-ci-dev/npm --save-dev

github.com/aspnet/SignalR

thats, ,

    public override async Task OnConnectedAsync()
    {
        await Clients.Client(Context.ConnectionId).InvokeAsync("connectionmade", "connection made dude");

        await base.OnConnectedAsync();
    }

public async Task Send(string message)
{
    await Clients.All.InvokeAsync("Send",  message);
}
0
thanks that works but now docker image deployment breaks :(

are there any docs out there that can guide me to create my own aspnetcore 2.1 linux docker image  to deploy to?

-------------------------------------------------------------------
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).
0

Source: https://habr.com/ru/post/1683572/


All Articles