0
votes

I am getting an interesting error. I have upgraded both Castle and NServiceBus. Castle was using version 3, now using version 3.3.1. NServiceBus was using 3.2.7 and am now using 4.6.1.

My configuration

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

}

The error I am receiving is this:

Component NServiceBus.Scheduling.ScheduledTaskMessageHandler has lifestyle Bound but it does not specify mandatory 'scopeRootSelector'.

If anyone has any idea what I must change, please let me know. I have tried looking through all the configuration options and am not sure what I am missing. This is on a web interface to a service where the web ui and the service are hosted in two different places. The Web UI only takes information from the user and sends off messages to be processed with no expected return value. This is why I have it set as a SendOnly config.

UPDATE: Here is information that Sean Farmar asked for.

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

Server Error in '/ClientServices' Application.


Component NServiceBus.Scheduling.ScheduledTaskMessageHandler has lifestyle Bound but it does not specify mandatory 'scopeRootSelector'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Castle.MicroKernel.ComponentRegistrationException: Component NServiceBus.Scheduling.ScheduledTaskMessageHandler has lifestyle Bound but it does not specify mandatory 'scopeRootSelector'.

Source Error:

Line 191: Configure.Serialization.Xml(); Line 192: Line 193: Configure.With() Line 194: .CastleWindsorBuilder(container) Line 195: .UseTransport()

Source File: C:\ClientServices\trunk\src\UI\Global.asax.cs Line: 193

Stack Trace:

[ComponentRegistrationException: Component NServiceBus.Scheduling.ScheduledTaskMessageHandler has lifestyle Bound but it does not specify mandatory 'scopeRootSelector'.] 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.ComponentRegistration1.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(IEnumerable1 types) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Config\ConfigUnicastBus.cs:164 NServiceBus.Unicast.Config.ConfigUnicastBus.LoadMessageHandlers(IEnumerable1 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__DisplayClass231.b__20(Type t) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Configure.cs:555 System.Collections.Generic.List1.ForEach(Action1 action) +11010045 NServiceBus.Configure.ForAllTypes(Action1 action) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Configure.cs:379 NServiceBus.Configure.ActivateAndInvoke(Action1 action, Nullable`1 thresholdForWarning) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Configure.cs:549 NServiceBus.Configure.Initialize() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Configure.cs:350 NServiceBus.ConfigureExtensions.SendOnly(Configure config) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Config\ConfigureExtensions.cs:18 Lsr.ClientServices.UI.NServiceBusInstaller.Install(IWindsorContainer container, IConfigurationStore store) in C:\ClientServices\trunk\src\UI\Global.asax.cs:193 Castle.Windsor.Installer.AssemblyInstaller.Install(IWindsorContainer container, IConfigurationStore store) +229 Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope) +165 Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers) +227 Lsr.ClientServices.UI.MvcApplication.BootstrapContainer() in C:\ClientServices\trunk\src\UI\Global.asax.cs:52 Lsr.ClientServices.UI.MvcApplication.Application_Start() in C:\ClientServices\trunk\src\UI\Global.asax.cs:44

1
What is you container configuration code look like?Sean Farmar

1 Answers

0
votes

When applying DLLs for Castle, I mistakenly chose the DLLs from the "Net40-Client" folder. When re-evaluating everything, I decided to choose the DLLs from the "Net40" folder and they worked. This applied to the Castle.Windsor.DLL and Castle.Facilities.FactorySupport.DLL.

From my understanding, the only different between client and non-client is that the client version includes references to ASP.NET. If that is the only difference, I have no idea why I was receiving issues. Anyhow, switching to the "Net40" DLLs resolved my issue and I am no longer receiving the scopeRootSelector error.