title: StructureMap - Register Generic Type
body: <p>I have the following code:</p>
  
  <pre><code>public class Dispatcher : IDispatcher {
    public void Send(Order order) {
      var type = typeof(IOrderHandler&lt;&gt;).MakeGenericType(order.GetType());
      var handler = ObjectFactory.GetInstance(type);
    }
  }
  </code></pre>
  
  <p><strong>NOTE:</strong> I am trying to get the IOrderHandler where order in this case is: 
      public class CoffeOrder : Order { }</p>
  
  <p>My StructureMap configuration is the following:</p>
  
  <pre><code>ObjectFactory.Initialize(x =&gt; {
    x.For&lt;IOrderHandler&gt;().Use&lt;OrderHandler&gt;();
  });
  </code></pre>
  
  <p>When I debug it I get the following error:
  {"StructureMap configuration failures:\r\nError:  104\r\nSource:  Registry:  StructureMap.Configuration.DSL.Registry, StructureMap, Version=2.6.4.0, ...</p>
  
  <p>I tried other options but I always end up with a 104 error or a 202 error:
  "StructureMap Exception Code:  202\nNo Default Instance defined for PluginFamily Proj.Test.Tests+IOrderHandler`1[[Proj.Test.Tests+CoffeOrder, Proj.Test, ...</p>
  
  <p>NOTE: CoffeOrder is the type of the Order I am passing on my test.</p>
  
  <p>My code for a Handler class and interface is the following:</p>
  
  <pre><code>public class CoffeHandler : OrderHandler&lt;CoffeOrder&gt; {
    public override void Handle(CoffeOrder order) {
      // Some Code
    } // CoffeHandler
  } 
  
  public interface IOrderHandler {
    void Handle(Order order);
  } // IOrderHandler
  
  public interface IOrderHandler&lt;TOrder&gt; : IOrderHandler where TOrder : Order {
    void Handle(TOrder order);
  } // IOrderHandler
  
  public abstract class OrderHandler : IOrderHandler {
    public abstract void Handle(Order order);
  } // OrderHandler
  
  public abstract class OrderHandler&lt;TOrder&gt; : OrderHandler, IOrderHandler&lt;TOrder&gt; where TOrder : Order {
  
    public override void Handle(Order order) {
      TOrder torder = (TOrder)order;
      Handle(torder);
    } // Handle
  
    public abstract void Handle(TOrder order);
  
  } // OrderHandler
  </code></pre>
  
  <p>Could someone, please, help me out?</p>
  
  <p>Thank You,
  Miguel</p>