Note that there are some explanatory texts on larger screens.

plurals
  1. POSignalR IAssemblyLocator override not firing
    primarykey
    data
    text
    <p>I have a simple app which uses several hubs, some in the same project and one in another class library, and everything is working fine. Now I want to try and load a hub that's been created at run-time using CSharpCodeProvider.CompileAssemblyFromSource, and have my client communicate with that hub. It's not showing up in /signalr/hubs/.</p> <p>As one of several things I'm trying to get working, I'm trying to use a custom IAssemblyLocator as described here:</p> <p><a href="https://github.com/SignalR/SignalR/wiki/Extensibility" rel="nofollow">https://github.com/SignalR/SignalR/wiki/Extensibility</a></p> <p>But my GetAssemblies() code isn't being called as far as I can tell. This is my Global.asax.cs:</p> <pre><code>protected void Application_Start() { GlobalHost.DependencyResolver.Register(typeof(IAssemblyLocator), () =&gt; new AssemblyLocator()); var config = new HubConfiguration { EnableCrossDomain = true }; RouteTable.Routes.MapHubs(config); AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); } </code></pre> <p>and custom IAssemblyLocator:</p> <pre><code>public class AssemblyLocator : IAssemblyLocator { public IList&lt; Assembly &gt; GetAssemblies() { throw new Exception("I will break stuff"); IList&lt;Assembly&gt; allAsms = BuildManager.GetReferencedAssemblies().Cast&lt;Assembly&gt;().ToList(); foreach( Assembly asm in HubFactory.HubAssemblies ) { allAsms.Add( asm ); } return allAsms; } } </code></pre> <p>As you can see the first thing I'm doing is throwing an exception, just to prove that this code is being called, but it doesn't get thrown. With this code in place my application continues to work as normal, and my page/client can still send messages to my hubs.</p> <p>For background, I would like several separate data feeds working on the same web page, using the one connection, using hubs created at run-time rather than compile time. So I need to be able to create and load a hub at run-time, have it appear in /signalr/hubs/. I'm pretty sure my run-time created hub is OK - I've taken the generated code, stuck it into a regular .cs file and included it at compile time, and it then shows up OK in /signalr/hubs. Don't seem to be able to use groups with one hub, because of the shared connection. I should be able to find my run-time created hubs fine using GetHubContext(string).</p> <p>All ideas welcome!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload