Search code examples
c#model-view-controllerioc-containerlight-inject

LightInject SignalR missing .RegisterHubs method


I just started using LightInject for my MVC project and it's working just fine. But i wanted to use it for my SignalR hubs too. So i followed the instructions at http://www.lightinject.net/#signalr. However i cannot see the method ServiceContainer.RegisterHubs anywhere. I have installed the LightInject, LightInject.Mvc and LightInject.SignalR dll's.

using log4net.Config;
using LightInject;
using Microsoft.Owin;   
using Owin;
using MvcProject;
using MvcProject.ApplicationServices.Interfaces.EventSignups;

[assembly: XmlConfigurator(ConfigFile = "Web.config", Watch = true)]
[assembly: OwinStartup(typeof (Startup))]

namespace MvcProject
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            //ConfigureAuth(app);
            var container = new ServiceContainer();
            container.Register<IEventSignupService>();
            container.Register<IViewModelRetrieverEventCommentService>();
            container.Register<IViewModelRetrieverEventService>();
            container.RegisterHubs(); //cannot see method

            app.MapSignalR(container.EnableSignalR());
        }
    }
}

Anyone knows what i'm doing wrong?


Solution

  • Unfortunately this is just bad documentation. The method does not exist and never existed. You have to register each and every hub manually within your LightInject Container.

    Also, be aware of issues I've encountered by changing the DependencyResolver within SignalR for LightInject.

    PS: I know my answer is late but still tought it could be useful for people searching for the same issue.