Today I ran into an interesting issue. In my current project, we’re making a web application out of discrete modules. These modules should not expose their internal workings to the outside, to minimize assembly versioning issues. So we’ll ILMerge all non-public dependencies into the assembly.
One example is using SignalR. One of my modules uses signalr to notify clients. This is an internal implementation detail of my module, so it shouldn’t be exposed to the outside world.
The nice thing of this approach is, we can have multiple versions of the same assembly running in the same appdomain. So if I want another module to use a different version of signalr, there’s no issue at all.
But then I ran into a snag. SignalR requires it’s hubs to be public. But, if my hub is public, I’m exposing SignalR and I can’t ILMerge this dependency.
So how to solve this? After a bit of digging, it’s the IHubDescriptorProvider that finds the hubs. I’ve created a provider that finds ‘only’ my hub, but it’s not difficult to see how to fetch all hubs if you want to.
One little caveat that had me pulling out my hair. On the hubdescriptor, don’t specify the ‘NameSpecified’ flag, unless you actually have the HubNameAttribute on your hub. Else it will silently eat your outbound messages.