title: Can't register Mediatr automatically trough structuremap IoC
body: <p>I have a web application with multilayer architecture and the classes of handlers and queries in the separate layer from a structuremap configuration. I tried to register all handlers and queries dynamically but I couldn't.When I try to run the application I receive the runtime error:</p>
  
  <p>No default Instance is registered and cannot be automatically determined for type 'IRequestHandler'
  There is no configuration specified for IRequestHandler</p>
  
  <pre><code>        public DefaultRegistry() {
          Scan(
              scan =&gt; {
                  scan.TheCallingAssembly();
                  scan.WithDefaultConventions();
                  scan.AssemblyContainingType&lt;DefaultRegistry&gt;();
                  scan.AssemblyContainingType&lt;IMediator&gt;();
                  scan.ConnectImplementationsToTypesClosing(typeof(IRequestHandler&lt;,&gt;));
                  scan.ConnectImplementationsToTypesClosing(typeof(IAsyncRequestHandler&lt;,&gt;));
                  scan.ConnectImplementationsToTypesClosing(typeof(IRequestHandler&lt;&gt;));
                  scan.ConnectImplementationsToTypesClosing(typeof(IAsyncRequestHandler&lt;&gt;));
                  scan.ConnectImplementationsToTypesClosing(typeof(INotificationHandler&lt;&gt;));
                  scan.ConnectImplementationsToTypesClosing(typeof(IAsyncNotificationHandler&lt;&gt;));
                  scan.ConnectImplementationsToTypesClosing(typeof(IRepository&lt;&gt;));
                  scan.With(new ControllerConvention());
              });
          //For&lt;IExample&gt;().Use&lt;Example
          For&lt;SingleInstanceFactory&gt;().Use&lt;SingleInstanceFactory&gt;(ctx =&gt; t =&gt; ctx.GetInstance(t));
          For&lt;MultiInstanceFactory&gt;().Use&lt;MultiInstanceFactory&gt;(ctx =&gt; t =&gt; ctx.GetAllInstances(t));
          For&lt;IMediator&gt;().Use&lt;Mediator&gt;();
          For&lt;IUnitOfWork&gt;().Use&lt;UnitOfWork&gt;().LifecycleIs&lt;TransientLifecycle&gt;();
          For(typeof(IRequestHandler&lt;,&gt;)).DecorateAllWith(typeof(Business.Pipeline.MediatorPipeline&lt;,&gt;));
      }
  </code></pre>
  
  <p>controller 
  <code>var query = new GetUserQuery(id);var user = _mediator.Send(query);</code></p>
  
  <p>query</p>
  
  <pre><code>    public class GetUserQuery : IRequest&lt;User&gt;
  {
      public GetUserQuery() { }
      public GetUserQuery(int id)
      {
          Id = id;
      }
  
      public int Id { get; set; }
  }
  </code></pre>
  
  <p>handler</p>
  
  <pre><code> public class GetUserHandler : IRequestHandler&lt;GetUserQuery, User&gt;
  {
      private readonly IUnitOfWork _uow;
      public GetUserHandler(IUnitOfWork uow)
      {
          _uow = uow;
      }
  
      public User Handle(GetUserQuery message)
      {
          return _uow.UserRepository.Get(message.Id);
      }
  }
  </code></pre>