title: Scope gets lost in Castle Windsor typed factory?
body: <p>I have following Windsor component registration code in a container with TypedFactoryFacility:</p>
  
  <pre><code>Component
      .For&lt;IMyItemFactory&gt;()
      .AsFactory(f =&gt; f.SelectedWith(new MyComponentSelector()))
      .LifestylePerWcfOperation(),
  
  Classes
      .FromAssembly(Assembly.GetExecutingAssembly())
      .BasedOn&lt;IMyItem&gt;()
      .LifestylePerWcfOperation()
      .Configure(c =&gt; c.Named(c.Implementation.Name)),
  </code></pre>
  
  <p>that strives to create autoimplementation of IMyItemFactory. During execution of IMyItemFactory factory method program fails with exception</p>
  
  <pre><code>Castle.MicroKernel.ComponentResolutionException: Could not obtain scope for component SpecificItem. This is most likely either a bug in custom IScopeAccessor or you're trying to access scoped component outside of the scope (like a per-web-request component outside of web request etc)
     at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.GetScope(CreationContext context)
     at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
     at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden&amp; burden)
     at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
     at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
     at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)
     at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(String key, Type service, IDictionary arguments, IReleasePolicy policy)
     at Castle.Facilities.TypedFactory.TypedFactoryComponentResolver.Resolve(IKernelInternal kernel, IReleasePolicy scope)
     at Castle.Facilities.TypedFactory.Internal.TypedFactoryInterceptor.Resolve(IInvocation invocation)
     at Castle.Facilities.TypedFactory.Internal.TypedFactoryInterceptor.Intercept(IInvocation invocation)
     at Castle.DynamicProxy.AbstractInvocation.Proceed()
     at Castle.Proxies.IMyItemFactoryProxy.GetMyItem(String myItemType)
  </code></pre>
  
  <p>It's confusing as practically every component in the application has WcfOperation scope, so I don't understand how this can happen. I even try to log every registered type with its scope to assert that IMyItem classes have WcfOperation scope – and they have.</p>
  
  <p>Do you have any idea how to debug this?</p>
  
  <p>Edit: I am calling the factory from successfully constructed object with WcfOperation-scope that calls another WcfOperation-scoped services without a problem:</p>
  
  <pre><code>public SomeDataProvider(IElasticsearchClient elasticClient, IMyItemFactory factory)
  {
      _elasticClient = elasticClient;
  
      _factory = factory;
  }
  
  async Task SomeMethod()
  {
      var someString = await _elasticClient.SomeMethod(); // ok
  
      var myItem = _factory.GetMyItem(someString); // exception from above
  
      // ...
  }
  </code></pre>