我收到了一个有趣的错误。我已经升级了Castle和NServiceBus。 Castle使用的是版本3,现在使用的是版本3.3.1。 NServiceBus使用的是3.2.7,现在使用的是4.6.1。
我的配置
/// <summary>
/// Castle Windsor Installer for NServiceBus
/// </summary>
public class NServiceBusInstaller : IWindsorInstaller {
public void Install(IWindsorContainer container, IConfigurationStore store) {
Configure.Serialization.Xml();
Configure.With()
.CastleWindsorBuilder(container)
.UseTransport<Msmq>()
.UnicastBus()
.SendOnly();
}
}
我收到的错误是:
组件NServiceBus.Scheduling.ScheduledTaskMessageHandler具有生活方式绑定,但它没有指定强制性&#35; scopeRootSelector&#39;。
如果有人知道我必须改变什么,请告诉我。我试过查看所有配置选项,但不确定我缺少什么。这是在服务的Web界面上,其中web ui和服务托管在两个不同的地方。 Web UI仅从用户获取信息,并发送要处理的消息,而没有预期的返回值。这就是我将它设置为SendOnly配置的原因。
更新:这是Sean Farmar要求的信息。
private static IWindsorContainer _container;
private static void BootstrapContainer() {
_container = new WindsorContainer().Install(FromAssembly.This());
var controllerFactory = new WindsorControllerFactory(_container.Kernel);
ControllerBuilder.Current.SetControllerFactory(controllerFactory);
}
/// <summary>
/// IOC instructions to load Controllers via Castle.Windsor
/// </summary>
public class WindsorControllerFactory : DefaultControllerFactory {
private readonly IKernel _kernel;
public WindsorControllerFactory(IKernel kernel) {
_kernel = kernel;
}
public override void ReleaseController(IController controller) {
_kernel.ReleaseComponent(controller);
}
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) {
if (controllerType == null) {
throw new HttpException(404, string.Format("The controller for path '{0}' could not be found.",
requestContext.HttpContext.Request.Path));
}
return (IController)_kernel.Resolve(controllerType);
}
}
/// <summary>
/// Castle Windsor Installer for Controllers
/// </summary>
public class ControllersInstaller : IWindsorInstaller {
public void Install(IWindsorContainer container, IConfigurationStore store) {
container.Register(Classes.FromThisAssembly()
.BasedOn<IController>()
.LifestyleTransient());
}
}
/// <summary>
/// Facility to configure NHibernate
/// </summary>
public class PersistenceFacility : AbstractFacility {
protected override void Init() {
var config = BuildDatabaseConfiguration();
Kernel.Register(
Component.For<ISessionFactory>()
.UsingFactoryMethod(_ => config.BuildSessionFactory()),
Component.For<ISession>()
.UsingFactoryMethod(x => x.Resolve<ISessionFactory>().OpenSession())
);
}
private NHibernate.Cfg.Configuration BuildDatabaseConfiguration() {
return Fluently.Configure()
.Database(SetupDatabase())
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<ClientServicesUploadsMap>())
.BuildConfiguration();
}
protected virtual IPersistenceConfigurer SetupDatabase() {
return MsSqlConfiguration.MsSql2005.ConnectionString(
c => c.FromConnectionStringWithKey("workflow"));
}
}
/// <summary>
/// Castle Windsor Facility Installer
/// </summary>
public class FacilityInstaller : IWindsorInstaller {
public void Install(IWindsorContainer container, IConfigurationStore store) {
container.AddFacility<PersistenceFacility>();
}
}
/// <summary>
/// Castle Windsor Installer for Repositories
/// </summary>
public class RepositoriesInstaller : IWindsorInstaller {
public void Install(IWindsorContainer container, IConfigurationStore store) {
container.Register(Classes.FromAssemblyContaining<ClientServicesUploadsRepository>() .Where(Component.IsInSameNamespaceAs<ClientServicesUploadsRepository>())
.WithService.DefaultInterfaces()
.LifestyleTransient()
);
}
}
/// <summary>
/// Castle Windsor Installer for NServiceBus
/// </summary>
public class NServiceBusInstaller : IWindsorInstaller {
public void Install(IWindsorContainer container, IConfigurationStore store) {
Configure.Serialization.Xml();
Configure.With()
.CastleWindsorBuilder(container)
.UseTransport<Msmq>()
.UnicastBus()
.SendOnly();
}
&#39; / ClientServices&#39;中的服务器错误应用
组件NServiceBus.Scheduling.ScheduledTaskMessageHandler具有生活方式绑定,但它没有指定强制性的scopeRootSelector&#39;。 描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:Castle.MicroKernel.ComponentRegistrationException:组件NServiceBus.Scheduling.ScheduledTaskMessageHandler具有生活方式绑定但它没有指定强制性的scopeRootSelector&#39;。
来源错误:
第191行:Configure.Serialization.Xml(); 第192行: 第193行:Configure.With() 第194行:.CastleWindsorBuilder(容器) 第195行:.UseTransport()
源文件:C:\ ClientServices \ trunk \ src \ UI \ Global.asax.cs行:193
堆栈追踪:
[ComponentRegistrationException:组件NServiceBus.Scheduling.ScheduledTaskMessageHandler具有生活方式绑定但它没有指定强制性的&#35; scopeRootSelector&#39;。
Castle.MicroKernel.DefaultKernel.CreateScopeAccessorForBoundLifestyle(ComponentModel model)+212
Castle.MicroKernel.DefaultKernel.CreateLifestyleManager(ComponentModel model,IComponentActivator activator)+182
Castle.MicroKernel.Handlers.DefaultHandler.InitDependencies()+ 148
Castle.MicroKernel.Handlers.AbstractHandler.Init(IKernelInternal kernel)+171
Castle.MicroKernel.Handlers.DefaultHandlerFactory.Create(ComponentModel model)+71
Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.CreateHandler(ComponentModel model)+133
Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel model)+50
Castle.MicroKernel.Registration.ComponentRegistration 1.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) +267
Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations) +178
Castle.Windsor.WindsorContainer.Register(IRegistration[] registrations) +59
NServiceBus.ObjectBuilder.CastleWindsor.WindsorObjectBuilder.NServiceBus.ObjectBuilder.Common.IContainer.Configure(Type concreteComponent, DependencyLifecycle dependencyLifecycle) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\ObjectBuilder.CastleWindsor\WindsorObjectBuilder.cs:89
NServiceBus.ObjectBuilder.Common.CommonObjectBuilder.ConfigureComponent(Type concreteComponent, DependencyLifecycle instanceLifecycle) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\ObjectBuilder\Common\CommonObjectBuilder.cs:54
NServiceBus.Unicast.Config.ConfigUnicastBus.ConfigureMessageHandlersIn(IEnumerable
1种类型)在y:\ BuildAgent \ work \ 31f8c64a6e8a2d7c \ src \ NServiceBus.Core \ Unicast \ Config \ ConfigUnicastBus.cs:164
NServiceBus.Unicast.Config.ConfigUnicastBus.LoadMessageHandlers(IEnumerable 1 orderedTypes) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Config\ConfigUnicastBus.cs:147
NServiceBus.Unicast.Config.ConfigUnicastBus.LoadMessageHandlers() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Config\ConfigUnicastBus.cs:98
NServiceBus.EnsureLoadMessageHandlersWasCalled.Init() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\ConfigureUnicastBus.cs:49
NServiceBus.Configure.<Initialize>b__10(INeedInitialization t) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Configure.cs:350
NServiceBus.<>c__DisplayClass23
1.b__20(类型t)在y:\ BuildAgent \ work \ 31f8c64a6e8a2d7c \ src \ NServiceBus.Core \ Configure.cs:555
System.Collections.Generic.List 1.ForEach(Action
1 action)+11010045
在y:\ BuildAgent \ work \ 31f8c64a6e8a2d7c \ src \ NServiceBus.Core \ Configure.cs:549中的NServiceBus.Configure.ForAllTypes(Action 1 action) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Configure.cs:379
NServiceBus.Configure.ActivateAndInvoke(Action
1 action,Nullable`1 thresholdForWarning)
在y:\ BuildAgent \ work \ 31f8c64a6e8a2d7c \ src \ NServiceBus.Core \ Configure.cs中的NServiceBus.Configure.Initialize():350
NS中的NServiceBus.ConfigureExtensions.SendOnly(配置配置):\ BuildAgent \ work \ 31f8c64a6e8a2d7c \ src \ NServiceBus.Core \ Config \ ConfigureExtensions.cs:18
在C:\ ClientServices \ trunk \ src \ UI \ Global.asax.cs中的Lsr.ClientServices.UI.NServiceBusInstaller.Install(IWindsorContainer容器,IConfigurationStore存储):193
Castle.Windsor.Installer.AssemblyInstaller.Install(IWindsorContainer容器,IConfigurationStore商店)+229
Castle.Windsor.WindsorContainer.Install(IWindsorInstaller []安装程序,DefaultComponentInstaller范围)+165
Castle.Windsor.WindsorContainer.Install(IWindsorInstaller []安装程序)+227
在C:\ ClientServices \ trunk \ src \ UI \ Global.asax.cs中的Lsr.ClientServices.UI.MvcApplication.BootstrapContainer():52
在C:\ ClientServices \ trunk \ src \ UI \ Global.asax.cs中的Lsr.ClientServices.UI.MvcApplication.Application_Start():44
答案 0 :(得分:0)
在为Castle应用DLL时,我错误地从&#34; Net40-Client&#34;中选择了DLL。夹。在重新评估所有内容时,我决定从&#34; Net40&#34;中选择DLL。文件夹,他们工作。这适用于Castle.Windsor.DLL和Castle.Facilities.FactorySupport.DLL。
根据我的理解,客户端和非客户端之间的唯一区别是客户端版本包含对ASP.NET的引用。如果这是唯一的区别,我不知道为什么我会收到问题。无论如何,切换到&#34; Net40&#34; DLL解决了我的问题,我不再收到scopeRootSelector错误。