Domanda

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 ServerEndpoint implements NServiceBus.IWantToRunWhenTheBusStopsAndStarts. Its constructor takes a dependency on StructureMap.IContainer in order to get the container to use in the initializtion routine, Start(). I've added the dependencies to use StructureMap 2.6.4 with NServiceBus to the project.

However, I keep getting a System.EntryPointNotFoundException exception with the message "Entry point was not found" when I start the endpoint:

2014-01-07 23:16:30,581 [14] ERROR NServiceBus.Unicast.UnicastBus [(null)] <(null)> - 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.<>c__DisplayClass1d.<Start>b__1b() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 804 could not be started.

My Startup class:

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; }
 }

The initialization routine:

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);
}

The endpoint config:

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);
    }
}

I'm not running this code within a web application (obviously?).

I've done the following to attempt to resolve the problem:

  • Check the versions of referenced assemblies for conflicts
  • Create a local container variable in InitCommerceServices, like container = StructureMap.ObjectFactory.Container; instead of using dependency injection.
È stato utile?

Soluzione

It turned out to be a conflict between different versions of StructureMap. (There are many meanings to System.EntryPointNotFoundException). The original StructureMap dll was from EPiServer, and installed in the GAC. The newer StructureMap was from NServiceBus's nuget package for StructureMap. I resolved the conflict between the two versions by adding a binding redirect in each endpoint's App.config under <configuration>/<runtime> element as described in this msdn page

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="StructureMap" publicKeyToken="e60ad81abae3c223" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.4.0" newVersion="2.6.4.0" />
    </dependentAssembly>
</assemblyBinding>

Side note: NuGet is supposed to add the binding redirect for you automatically when you upgrade a package. I don't know if it does that when a package is installed, instead of upgraded. Because we're using SlowCheetah, I'll never know if it did that in this case. The config file transforms use our own file as the source App.config and would have overwritten the files when generated. (Perhaps this problem makes a case for using the original file as the source of a SlowCheetah transfom.)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top