Hi!

I'm using a custom lifestyle scope in order to create component based on a
value stored on the thread level.
Typically, each call to my WCF service require a user authentication, and
user is linked to a customer. And I want 1 component for each customer, no
matter how many users (linked to this customer) are connected.

So I created the PerCompanyScopeAccessor which is quite simple (see
attachment)

Problem:
If I've several concurrent request on the service, which call the Resolve
method for this component, I've this crash:

System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue
value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Castle.MicroKernel.Lifestyle.Scoped.ScopeCache.set_Item(Object id,
Burden value)
   at
Castle.MicroKernel.Lifestyle.Scoped.DefaultLifetimeScope.GetCachedInstance(ComponentModel
instance, ScopedInstanceActivationCallback createInstance)
   at
Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.Resolve(CreationContext
context, IReleasePolicy releasePolicy)
   at
Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext
context, Boolean requiresDecommission, Boolean instanceRequired, Burden&
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(Type
service, IDictionary arguments, IReleasePolicy policy)
   at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary
arguments)
   at Castle.Windsor.WindsorContainer.Resolve(Type service)


In my PerCompanyScopeAccessor I try to handle concurrent access using a
ConcurrentCollection, but it seems the crash come from the ScopeCache ?

Does someone know what happen there ?

Thank you for any help,
Fabrice

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Attachment: PerCompanyScopeAccessor.cs
Description: Binary data

Reply via email to