title: Using StructureMap 3 in multiple ASP MVC projects
body: <p>First lets start to describe my project architecture.<br/>
  I have a asp.net mvc application called <code>Portal.Web</code> as startup project and multiple asp.net mvc applications which called <code>Plugin.XXX</code> (Plugin.News, Plugin.Cms, etc) and <code>Portal.Web</code> has references from all of these plugins.<br/>
  I installed <code>StrcutureMap.Mvc5</code> for each one of these <code>Plugins</code><br/>
  As you know, when you install <code>StructureMap</code> a folder created called <code>DependencyResolution</code> and it contains some files, one of them is <code>IoC.cs</code> where you can initialize your container.<br/>
  Now my problem is since all plugins has their own <code>IoC.cs</code>, it seems like they override each other containers so at the end I get this error :</p>
  
  <pre><code>No parameterless constructor defined for this object
  
  // inner exception
  No default Instance is registered and cannot be automatically determined for type 'Portal.Plugins.Page.Interfaces.IPage'
  There is no configuration specified for Portal.Plugins.Page.Interfaces.IPage
  1.) new RouteController(*Default of IUnitOfWork*, *Default of IPage*)
  2.) Portal.Web.Controllers.RouteController
  3.) Instance of Portal.Web.Controllers.RouteController
  4.) Container.GetInstance(Portal.Web.Controllers.RouteController)
  
  There is no configuration specified for Portal.Plugins.Page.Interfaces.IPage
  </code></pre>
  
  <p>I could use ONE <code>IoC.cs</code> in <code>Portal.Web</code> project but I need to keep modularity and make Plugins independent as much as possible.<br/>
  is there any way to keep plugins containers independent?
  <br/>
  <br/></p>
  
  <pre><code>namespace Portal.Plugins.Account.DependencyResolution {
      using StructureMap;
  
      public static class IoC {
          public static IContainer Initialize() {
              return new Container(c =&gt;
              {
                  c.AddRegistry&lt;DefaultRegistry&gt;();
                  c.For&lt;IUnitOfWork&gt;().LifecycleIs(new HttpContextLifecycle()).Use&lt;AccountDbContext&gt;();
                  c.For&lt;IAccount&gt;().Use&lt;AccountService&gt;();
              });
          }
      }
  }
  </code></pre>
  
  <p><br/></p>
  
  <pre><code>namespace Portal.Plugins.Cms.DependencyResolution {
      using StructureMap;
  
      public static class IoC {
          public static IContainer Initialize() {
              return new Container(c =&gt;
              {
                  c.AddRegistry&lt;DefaultRegistry&gt;();
                  c.For&lt;IUnitOfWork&gt;().LifecycleIs(new HttpContextLifecycle()).Use&lt;CmsDbContext&gt;();
                  c.For&lt;IPage&gt;().Use&lt;PageService&gt;();
                  c.For&lt;IMenu&gt;().Use&lt;MenuService&gt;();
                  c.For&lt;IMedia&gt;().Use&lt;MediaService&gt;();
              });
          }
      }
  }
  </code></pre>