Note that there are some explanatory texts on larger screens.

plurals
  1. PONServiceBus 4 and custom SagaPersister
    text
    copied!<p>After migrating to NServiceBus 4 (from 3.3.7 to 4.0.5) I am trying to run my custom Saga Persister. I am registering it in container (one I use in whole web application), but during application startup I get exception:</p> <blockquote> <p>[ComponentResolutionException: Looks like you are trying to resolve a component which depends (directly or indirectly) on component which is lifestyle is PerWebRequest. Currently executed code is not in the web request scope.Analyze your dependencies and change their lifestyles (to signletons) or their dependencies.] CustomApp.Mapping.WebRequestFallingBackToCallContextScopeAccessor.GetScope(CreationContext context) in c:\tfs\Main\src\AppName2\CustomApp\CustomApp.Mapping\WebRequestFallingBackToCallContextScopeAccessor.cs:40 Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.GetScope(CreationContext context) +33 Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy) +84 Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden&amp; burden) +282 Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired) +35 Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency) +170 Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency) +38 Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context) +430 Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context) +52 Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context) +30 Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden) +27 Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally) +57 Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy) +29 Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden&amp; burden) +282 Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired) +35 Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy) +154 Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) +74 NServiceBus.Config.DisplayInfrastructureServicesStatus.Run() in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Config\InfrastructureServices.cs:163 System.Collections.Generic.List<code>1.ForEach(Action</code>1 action) +14013700 NServiceBus.Configure.Initialize() in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Configure.cs:374 NServiceBus.Configure.CreateBus() in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Configure.cs:307 CustomApp.Web.Initialization.BusInstaller.Install(IWindsorContainer container, IConfigurationStore store) in c:\tfs\Main\src\AppName2\CustomApp\CustomApp.Web\Initialization\BusInstaller.cs:56 Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope) +216 Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers) +124 CustomApp.Web.WindsorContainerProvider.GetInitializedContainer() in c:\tfs\Main\src\AppName2\CustomApp\CustomApp.Web\WindsorContainerProvider.cs:87 CustomApp.Web.MvcApplication.GetInitializedContainer() in c:\tfs\Main\src\AppName2\CustomApp\CustomApp.Web\Global.asax.cs:265 CustomApp.Web.MvcApplication.Application_Start() in c:\tfs\Main\src\AppName2\CustomApp\CustomApp.Web\Global.asax.cs:139 CustomApp.Administration.Web.Global.Application_Start() in c:\tfs\Main\src\AppName2\CustomApp\Administration\CustomApp.Administration.Web\Global.asax.cs:11</p> </blockquote> <p>Any ideas how to resolve this issue? The same code base worked smoothly NServiceBus 3.3.7</p> <p><strong>EDIT:</strong> This is how I init NSB:</p> <pre><code> Configure.Serialization.Xml(); Configure.Features.Enable&lt;SecondLevelRetries&gt;(); Configure.Features.Enable&lt;TimeoutManager&gt;(); Configure.Features.Enable&lt;Sagas&gt;(); var conf = Configure.With(assemblies) .CustomConfigurationSource(new BusConfigSource(assemblies)) .DefineEndpointName(ConfigurationManager.AppSettings["EndpointName"]) .CastleWindsorBuilder(container) .UseTransport&lt;Msmq&gt;() .UseInMemoryTimeoutPersister() .PurgeOnStartup(false) .FileShareDataBus(WebConfigurationManager.AppSettings["NServiceBusFileShare"]) .UnicastBus() .LoadMessageHandlers() .MsmqSubscriptionStorage(); conf.Configurer.ConfigureComponent&lt;CustomSagaPersister&gt;(DependencyLifecycle.InstancePerCall); conf.CreateBus().Start(() =&gt; Configure.Instance.ForInstallationOn&lt;Windows&gt;().Install()); </code></pre> <p>I also tried the approach with manualy adding my CustomSagaPersiter to container and without calling </p> <pre><code>conf.Configurer.ConfigureComponent&lt;CustomSagaPersister&gt;(DependencyLifecycle.InstancePerCall); </code></pre> <p>But the result is the same.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload