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)
- 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
- , ,
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.AddSockets();
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
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 = negotiatePayload;
this.connectionId = negotiateResponse;
if (this.connectionState == ConnectionState.Disconnected) {
return;
}
this.url += (this.url.indexOf("?") == -1 ? "?" : "&") + `id=${this.connectionId}`;
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;
var [lenStr, offset] = splitAt(input, ":", offset);
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
but that doesnt work so i went with the original one from the video
npm install signalr-client
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