Hi there, 
        
The issue IOC-ISSUE-138 was just created by Jonne Kats (jonnekats).
        
        Key: IOC-ISSUE-138
        Summary: Resolve sub component with dictionary in constructor throw 
exception
        Type: Bug
        Importance: Medium
        
        Description:
        Consider the following test, where the ServiceContainer is just a 
static wrapper around the Windsor container:
        public class A
        {
                private B b;
                
                public A(string test)
                {
                        IDictionary parameters = new ListDictionary();
                        parameters.Add("test2", "bla");
                        b = ServiceContainer.Resolve<B>(parameters);
                }
        }
        
        public class B
        {
                public B(string test2)
                {
                        
                }
        }
        [TestClass]
        public class ServiceContainerTest
        {
                [TestMethod]
                public void TestResolveSubComponentInConstructorWithParameters()
                {
                        ServiceContainer.Current.AddComponent("A", typeof(A));
                        ServiceContainer.Current.AddComponent("B", typeof(B));
                        IDictionary parameters = new ListDictionary();
                        parameters.Add("test", "bla");
                        
                        A a = ServiceContainer.Resolve<A>(parameters);
                        Assert.IsNotNull(a);
                }
        }
This throws the following exception:
Castle.MicroKernel.ComponentActivator.ComponentActivatorException: 
ComponentActivator: could not instantiate IJM.Library.Test.IoC.A
        Castle.MicroKernel.ComponentActivator.ComponentActivatorException: 
ComponentActivator: could not instantiate IJM.Library.Test.IoC.A ---> 
System.Reflection.TargetInvocationException: Exception has been thrown by the 
target of an invocation. ---> 
Castle.MicroKernel.Resolvers.DependencyResolverException: Could not resolve 
non-optional dependency for 'B' (IJM.Library.Test.IoC.B). Parameter 'test2' 
type 'System.String'
        at 
Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext 
context, ISubDependencyResolver parentResolver, ComponentModel model, 
DependencyModel dependency)
This probably occurs because of the static CreationContext in the DefaultKernel.
        
For more, see 
http://support.castleproject.org/projects/IOC/issues/view/IOC-ISSUE-138
 
        
--
donjon
by Castle Stronghold
http://www.castle-donjon.com



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to