Signalr Hub in Separate Dll
I had a hub hosted in a console app with a WPF app connecting to it. It worked just fine. Then I moved the hub into a separate project and added a reference from the host to new project. Now I am getting a 500 error, with no other details.
Is there anything different that needs to be done in order to host a hub from another assemble/namespace?
Edit: I tried a few things after opening the question. Here is what I have tried so far:
Here is the exception that gets passed back. "System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at Microsoft.AspNet.SignalR.Client.Http.HttpHelper.<>c_DisplayClass2.b_0(IAsyncResult ar) at System.Threading.Tasks.TaskFactory 1.FromAsyncCoreLogic(IAsyncResult iar, Func
2 endFunction, Action 1 endAction, Task
1 promise, Boolean requiresSynchronization)"
This worked for me (in startup)
AppDomain.CurrentDomain.Load(typeof(MyHub).Assembly.FullName);
Credits to map hubs in referenced project
尝试查看http响应消息
try
{
hubConnection.Start().Wait();
}
catch (Exception error)
{
if (error.InnerException is WebException)
{
WebException webError = (WebException)error.InnerException;
Console.WriteLine(webError.Status);
Console.WriteLine(webError.Response);
}
}
Have you moved your call to register your hubs to the new dll? Ie the following needs to be in your new project (but still called from global.asax):
RouteTable.Routes.MapHubs();
You probably also need to use the [WebActivator PreApplicationStart attribute] (http://msdn.microsoft.com/en-us/library/system.web.preapplicationstartmethodattribute.aspx) in the new RegisterHubs class to ensure it is registered in time
链接地址: http://www.djcxy.com/p/96172.html上一篇: 在WebApi和MVC项目之间共享SignalR集线器
下一篇: 信号集线器在单独的dll中