An item with the same key has already been added. (Strategy type BuildPlanStrategy, index 3)"}

Jun 18, 2009 at 1:15 PM

Hello,

I use the following 3 lines to resolve a class instance with one constructor parameter. I am trying to register the parameter object with:

                container.RegisterInstance(typeof(ServerContext), this.ServerContext);
                section.Containers["myContainerName"].Configure(container);
                container.Resolve(typeof(myClassType));

I am using an external configuration file and the resolution fails with the message: "An item with the same key has already been added. (Strategy type BuildPlanStrategy, index 3)"}".
I believe that this is happening because the prameter object is null.The parameter needs to be set programmatically (since it will be out of state if i configure it in the config file).
How can i programmatically pass the initialized constructor parameter? I tried with InjectionConstructor but i got the same error again.

Help will be much appreciated.

Jun 19, 2009 at 3:01 AM
Edited Jun 19, 2009 at 3:02 AM

I need a lot more to go on. What's the stack trace? What's your config file look like? What's the full exception message?

Can you post a small but complete example that demonstrates the issue you're having?

 

Feb 27, 2010 at 6:38 AM

I am getting same exception while resolving the item from container.

 

Feb 27, 2010 at 4:34 PM

Can you post a small but complete example that demonstrates the issue you're having?