title: StructureMap Error: No Default Instance defined for PluginFamily
body: <p>very new to Structure-Map. trying to figure it out how it works and how can i benefit from it.</p>
  
  <p>i have got this so far..</p>
  
  <p><strong>Global.asax.cs:</strong></p>
  
  <pre><code>IContainer container = new Container(x =&gt;
      {
           x.For&lt;IControllerActivator&gt;().Use
                &lt;StructureMapControllerActivator&gt;();
           x.For&lt;IUserRepo&gt;().Use&lt;UserRepo&gt;();
      }); 
  
  DependencyResolver.SetResolver(new StructureMapDependencyResolver(container));
  </code></pre>
  
  <p><strong>StructureMapControllerActivator:</strong></p>
  
  <pre><code>public class StructureMapControllerActivator : IControllerActivator
  {
      private readonly IContainer _container;
  
      public StructureMapControllerActivator(IContainer container )
      {
          this._container = container;
      }
  
      public IController Create(RequestContext requestContext, Type controllerType)
      {
          return _container.GetInstance(controllerType) as IController;
      }
  }
  </code></pre>
  
  <p><strong>StructreMapDependencyResolver:</strong></p>
  
  <pre><code>private readonly IContainer _container;
  
      public StructureMapDependencyResolver(IContainer container )
      {
          this._container = container;
      }
  
      public object GetService(Type serviceType)
      {
          object instance = _container.TryGetInstance(serviceType);
          if(instance == null &amp;&amp; !serviceType.IsAbstract)
          {
              _container.Configure(c =&gt; c.AddType(serviceType,serviceType));
              instance = _container.TryGetInstance(serviceType);
          }
          return instance;
      }
  
      public IEnumerable&lt;object&gt; GetServices(Type serviceType)
      {
          return _container.GetAllInstances(serviceType).Cast&lt;object&gt;();
      }
  }
  </code></pre>
  
  <p><strong>My AccountController:</strong></p>
  
  <pre><code>public class AccountController : Controller
  {
      private readonly IUserRepo _userRepo;
  
      private AccountController()
      {
          _userRepo = ObjectFactory.GetInstance&lt;IUserRepo&gt;();
      }
  
      public ActionResult Login()
      {
          return View();
      }
  }
  </code></pre>
  
  <p><strong>Error Code &amp; Description:</strong></p>
  
  <blockquote>
    <p>StructureMap Exception Code:  202
    No Default Instance defined for PluginFamily MBP_Blog.Controllers.AccountController
    MBP-Blog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</p>
  </blockquote>
  
  <p>I have a Interface Name : IUserRepo and a repository Name: UserRepo</p>
  
  <p>please help as I try to google but dint find any solution within first 3 pages.</p>
  
  <p><strong>New error after using @Martin's code:</strong></p>
  
  <blockquote>
    <p>StructureMap Exception Code:  180
    StructureMap cannot construct objects of Class MBP_Blog.Controllers.AccountController, MBP-Blog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null because there is no public constructor found.</p>
  </blockquote>