1

I'm trying to inject Signalr dependencies with Funq D.I.

The process is explained pretty well here and I tried also to follow this question.

and the Ninject version works pretty well.

Now I am trying to convert it to a Funq version using this gist for FunqDependencyResolver. but this Funq version is not working and gives the "System.MissingMethodException: No parameterless constructor defined for this object" that should be because it's not registering dependencies.

Is this because the Ninject version is resolving to a method?

Community
  • 1
  • 1
Ronnie
  • 4,959
  • 10
  • 51
  • 69

1 Answers1

3

We used Windsor, but the process is the same for any IoC:

First create your resolver, inherit from signalR DefaultDependencyResolver:

public class CustomContainerResolver: DefaultDependencyResolver
{
        public CustomContainerResolver(IocContainer instance)
        {
            _instance = instance;
        }

        public override object GetService(Type serviceType)
        {
            return _instance.Instance.Kernel.HasComponent(serviceType) ? _instance.GetService(serviceType) : base.GetService(serviceType);
        }

        public override IEnumerable<object> GetServices(Type serviceType)
        {
            return _instance.Instance.Kernel.HasComponent(serviceType) ? _instance.GetAllInstances(serviceType): base.GetServices(serviceType);
        }
}

In your Startup:

var signalrDependency = new CustomContainerResolver(container);

then, as usual

app.MapSignalR(hubConfiguration);
penderi
  • 8,673
  • 5
  • 45
  • 62
  • 1
    I linked to the Funq dependency resolver I used in the original question and it's also very similar to the Ninject one that is working perfectly https://gist.github.com/aaronlerch/5345587 Apparently with Funq something is missing. – Ronnie Jan 20 '14 at 09:28