title: StructureMap Exception: "Entry point was not found" in NServiceBus project for EPiServer integration
body: <p>I'm attempting to initialize an NServiceBus (v4.3.2) endpoint that calls EPiServer.Framework (v7.0.859.1) and other Mediachase (v7.0.243) libraries to initialize access to the database. My class <code>ServerEndpoint</code> implements <code>NServiceBus.IWantToRunWhenTheBusStopsAndStarts</code>. Its constructor takes a dependency on <code>StructureMap.IContainer</code> in order to get the container to use in the initializtion routine, <code>Start()</code>. I've added the dependencies to use StructureMap 2.6.4 with NServiceBus to the project.</p>
  
  <p>However, I keep getting a <code>System.EntryPointNotFoundException</code> exception with the message "Entry point was not found" when I start the endpoint:</p>
  
  <pre><code>2014-01-07 23:16:30,581 [14] ERROR NServiceBus.Unicast.UnicastBus [(null)] &lt;(null)&gt; - System.EntryPointNotFoundException: Entry point was not found.
     at StructureMap.IContainer.Configure(Action`1 configure)
     at Mediachase.Commerce.Initialization.CommerceInitialization.ConfigureContainer(ServiceConfigurationContext context)
     at clin.Integration.Commerce.Initialization.InitCommerceServices(IContainer container1) in c:\dev\clin\kimball\Trunk\NServiceBus\clin.ServiceBus\clin.Integration.Commerce\Initialization.cs:line 18
     at clin.Web.CatalogChangeEndpoint.ServerEndpoint.Start() in c:\dev\clin\kimball\Trunk\NServiceBus\clin.ServiceBus\clin.Web.CatalogChangeEndpoint\CatalogChangeEndpoint.cs:line 26
     at NServiceBus.Unicast.UnicastBus.&lt;&gt;c__DisplayClass1d.&lt;Start&gt;b__1b() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 804 could not be started.
  </code></pre>
  
  <p>My Startup class:</p>
  
  <pre><code>class ServerEndpoint : IWantToRunWhenBusStartsAndStops
  {
      public ServerEndpoint(StructureMap.IContainer container)
      {
          _container = container;
      }
  
      public void Start()
      {
          Integration.Commerce.Initialization.InitCommerceServices(_container);
          Integration.Commerce.Catalog.InitCommerceCatalog();
      }
  
      public void Stop() { }
  
      public IContainer _container { get; set; }
   }
  </code></pre>
  
  <p>The initialization routine:</p>
  
  <pre><code>public static void InitCommerceServices(IContainer container)
  {
     var locator = new EPiServer.ServiceLocation.StructureMapServiceLocator(container);
     var context = new EPiServer.ServiceLocation.ServiceConfigurationContext(HostType.Undefined, container);
     new Mediachase.Commerce.Initialization.CommerceInitialization().ConfigureContainer(context);
     EPiServer.ServiceLocation.ServiceLocator.SetLocator(locator);
  }
  </code></pre>
  
  <p>The endpoint config:</p>
  
  <pre><code>public class EndpointConfig : IConfigureThisEndpoint, IWantCustomInitialization, AsA_Server
  {
      public void Init()
      {
          Configure.Serialization.Json();
          Configure.With()
              .StructureMapBuilder()
              .DefiningCommandsAs(MsgConvention.MessageConventions.IsCommandType)
              .DefiningEventsAs(MsgConvention.MessageConventions.IsEventType)
              .DefiningMessagesAs(MsgConvention.MessageConventions.IsInternalMessage);
      }
  }
  </code></pre>
  
  <p>I'm not running this code within a web application (obviously?).</p>
  
  <p>I've done the following to attempt to resolve the problem:</p>
  
  <ul>
  <li>Check the versions of referenced assemblies for conflicts</li>
  <li>Create a local container variable in InitCommerceServices, like <code>container = StructureMap.ObjectFactory.Container;</code> instead of using dependency injection.</li>
  </ul>