Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Duplicate Objects detected for Instance of Type
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Alexander Dolin  
View profile  
 More options May 17 2012, 9:45 am
From: Alexander Dolin <alex.do...@gmail.com>
Date: Thu, 17 May 2012 06:45:32 -0700 (PDT)
Local: Thurs, May 17 2012 9:45 am
Subject: Duplicate Objects detected for Instance of Type

Hi,

I'm getting the following exception from structure map -  "Duplicate
Objects detected for Instance d54e25dc-d19c-4d70-99d1-56bd2502d203 of Type
..."

The stack trace is:
at StructureMap.InstanceCache.Set(Type pluginType, Instance Instance,
Object result) in
c:\code\structuremap\Source\StructureMap\InstanceCache.cs:line 60
at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance
instance) in c:\code\structuremap\Source\StructureMap\BuildSession.cs:line
159
at StructureMap.BuildSession.<>c_DisplayClass3.<.ctor>b_1() in
c:\code\structuremap\Source\StructureMap\BuildSession.cs:line 34
at StructureMap.BuildSession.CreateInstance(Type pluginType) in
c:\code\structuremap\Source\StructureMap\BuildSession.cs:line 192
at StructureMap.BuildSession.GetInstance[T]() in
c:\code\structuremap\Source\StructureMap\BuildSession.cs:line 78

This exception happens only from time to time and is very difficult to
reproduce.

What I've found out so far:
Calling ObjectFactory.Container.GetInstance(type) will create a new
BuildSession with a new non-static cache.
The call will reach BuildSession.CreateInstance(Type pluginType, Instance
instance) and no instance is in the cache yet. (
https://github.com/structuremap/structuremap/blob/master/Source/Struc...
 147)
Now we'll go on to _builder.Resolve(pluginType, instance, this);
Somewhere during Resolve() the object will get into the cache and later
in CreateInstance we're saving it into the cache once again, receiving the
exception.

That object is configured with Singleton lifecycle. The application is WCF
service hosted in IIS.

I still cannot understand why sometimes that object gets into the cache
twice.
I'd like to ask for all the possible ways how this can happen in SM.

Thank you.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »