Closed harisbotic closed 7 years ago
This should be possible, give it a try.
public class Chat : Hub
{
private IP2PRepository _p2pRepo;
public Chat(IP2PRepository p2pRepo)
{
_p2pRepo = p2pRepo;
}
public override Task OnConnectedAsync()
{
System.Console.WriteLine("SOMEONE CONNECTED");
return Task.CompletedTask;
}
public override Task OnDisconnectedAsync()
{
System.Console.WriteLine("SOMEONE DISCONNECTED");
return Task.CompletedTask;
}
}
and the Error in console is
System.MissingMethodException: No parameterless constructor defined for this object.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance[T]()
at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()```
Oh yeah, I fixed that a few days ago. What version of Microsoft.AspNetCore.SignalR are you using?
Saw it just now... Thank you, I fixed it
And now, I can't get of this error whenever someone tries to connect
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.SignalR.JsonNetInvocationAdapter.<>c__DisplayClass2_0.<ReadInvocationDescriptorAsync>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<DispatchMessagesAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SignalR.HubEndPoint`2.<OnConnectedAsync>d__8.MoveNext()
Not related to this issue, look at #64 and #62
@harisbotic - hub method names are no longer fully qualified names but just method names.
I am having the same issue. I am not able to use DI in SignalR (1.0.0-alpha2-final) with AspNetCore (2.0.0). Any pointers
Can you make a minimal repro of the issue on GitHub?
@davidfowl, i tried to create new project using "dotnet new angular" cmd on VS Code. Now its throwing a weird error on the start of the application.
**
An unhandled exception occurred while processing the request.
NodeInvocationException: Uncaught (in promise): Error: Cannot resolve '/chat'. Error: Cannot resolve '/chat'.
**
Please find the repo @ https://github.com/avijassra/signalrDi. Thanks
@davidfowl , when i am trying to start the connection, i am getting this new error .... at this line
File -> https://github.com/avijassra/signalrDi/blob/v1-reboot/ClientApp/app/services/pubsub.service.ts#L16
this.connection = new HubConnection('chat'); //this.startedConnection = this.connection.start();
File -> https://github.com/avijassra/signalrDi/blob/v1-reboot/Startup.cs#L47
app.UseSignalR(routes => routes.MapHub
("chat"));
This is different issue then my DI issue as mentioned earlier .... thanks
@avijassra why not file a different bug then?
@davidfowl Done
Singleton not working in my app was a code issue and not SignalR issue. Thanks to @davidfowl for your time and help.
I wanted to access some repositories/services from within a hub, is that possible now? Will you implement this feature later?