In my case, my hubs are in a project referenced from the project code that spins up the self-hosted application.
On the line connection.Start().Wait();
I get an exception. The following is the sequence of exceptions thrown at that line:
- The specified registry key does not exist System.IO.IOException
- 'MessageHub' Hub could not be resolved InvalidOperationException
- The remote server returned an error: (500) Internal Server Error WebException
The signature of the message hub class in the referenced project is public class MessageHub : Hub
.
Update: To test the theory, I moved the hub class from the referenced project into my test project and updated the namespace. It worked. So I think the theory here is sound... default hub resolution does not find hubs in referenced project or in separate namespace.
How can I convince MapHubs to find the test hub in the referenced project?
I think that I have found an answer to this.
After doing some digging around the source code it seems that SignalR uses the following method to designate an IAssemblyLocator to locate Hubs.
This got me to try to simply add my external assembly to current domain because although it was referenced it was not being loaded.
So before calling WebApp.Start I call the following line.
Where Core.Chat is simply the Hub class I'm using. And then the hubs defined in referenced assembly are loaded.
There might be a more straight forward way to go about this but I could not find anything in the documentation.
Hope this helps.