title: Using Simple Injector with SignalR
body: <p>I thought using my own IoC would be pretty straight forward with SignalR and maybe it is; most likely I'm doing something wrong. Here's my code I have so far:</p>
  
  <pre><code>private static void InitializeContainer(Container container)
  {
  
     container.Register&lt;IMongoHelper&lt;UserDocument&gt;, MongoHelper&lt;UserDocument&gt;&gt;();
     // ... registrations like about and then:
     var resolver = new SimpleInjectorResolver(container);
     GlobalHost.DependencyResolver = resolver;
  }
  </code></pre>
  
  <p>and then my class:</p>
  
  <pre><code>public class SimpleInjectorResolver : DefaultDependencyResolver
  {
      private Container _container;
      public SimpleInjectorResolver(Container container)
      {
          _container = container;
      }
  
      public override object GetService(Type serviceType)
      {
          return _container.GetInstance(serviceType) ?? base.GetService(serviceType);
      }
  
      public override IEnumerable&lt;object&gt; GetServices(Type serviceType)
      {
          return _container.GetAllInstances(serviceType) ?? base.GetServices(serviceType);
      }
  }
  </code></pre>
  
  <p>What ends up happening is I get an error that IJavaScriptProxyGenerator can't be resolved, so I think, well I'll add the registration:</p>
  
  <pre><code>container.Register&lt;IJavaScriptProxyGenerator, DefaultJavaScriptProxyGenerator&gt;(
      ConstructorSelector.MostParameters);
  </code></pre>
  
  <p>but then there are a bunch of others! I get to:</p>
  
  <pre><code>container.Register&lt;IDependencyResolver, SimpleInjectorResolver&gt;();
  container.Register&lt;IJavaScriptMinifier, NullJavaScriptMinifier&gt;();
  container.Register&lt;IJavaScriptProxyGenerator, DefaultJavaScriptProxyGenerator&gt;(
      ConstructorSelector.MostParameters);
  container.Register&lt;IHubManager, DefaultHubManager&gt;();
  container.Register&lt;IHubActivator, DefaultHubActivator&gt;();
  container.Register&lt;IParameterResolver, DefaultParameterResolver&gt;();
  container.Register&lt;IMessageBus, InProcessMessageBus&gt;(ConstructorSelector.MostParameters);
  </code></pre>
  
  <p>Which still gives me "No registration for type <code>ITraceManager</code> could be found." ... but now I'm wondering if I'm doing this right at all as I hoping I wouldn't need to re-wire everything SignalR is doing...right? Hopefully? If not I'll keep trudging along but I'm a SignalR and Simple Injector newb so thought I'd ask first. :)</p>
  
  <p>Additional: <a href="https://cuttingedge.it/blogs/steven/pivot/entry.php?id=88" rel="noreferrer">https://cuttingedge.it/blogs/steven/pivot/entry.php?id=88</a> since SignalR had multiple constructors.</p>