我正在尝试初始化一个NServiceBus(v4.3.2)端点,该端点调用EPiServer.Framework(v7.0.859.1)和其他Mediachase(v7.0.243)库来初始化对数据库的访问。我的班级ServerEndpoint
实施NServiceBus.IWantToRunWhenTheBusStopsAndStarts
。它的构造函数依赖于StructureMap.IContainer
,以便在初始化例程Start()
中使用容器。我已经将依赖关系添加到项目中使用StructureMap 2.6.4和NServiceBus。
但是,当我启动端点时,我不断收到System.EntryPointNotFoundException
异常,并显示“找不到入口点”消息:
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.
我的启动课程:
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; }
}
初始化程序:
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);
}
端点配置:
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);
}
}
我没有在Web应用程序中运行此代码(很明显?)。
我已完成以下操作以尝试解决此问题:
container = StructureMap.ObjectFactory.Container;
,而不是使用依赖注入。答案 0 :(得分:4)
结果是不同版本的StructureMap之间存在冲突。 (有many meanings to System.EntryPointNotFoundException)。原始的StructureMap dll来自EPiServer,并安装在GAC中。较新的StructureMap来自NServiceBus的StructMap的nuget包。我解决了两个版本之间的冲突,通过在<configuration>/<runtime>
元素下的<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>
元素下的每个端点的App.config中添加绑定重定向,如in this msdn page
{{1}}
旁注: NuGet应该在升级包时自动为您添加绑定重定向。我不知道在安装软件包时是否这样做,而不是升级。因为我们正在使用SlowCheetah,所以在这种情况下,我永远不知道它是否会这样做。配置文件转换使用我们自己的文件作为源App.config,并在生成时覆盖文件。 (也许这个问题会将原始文件用作SlowCheetah变换器的来源。)