I've read his post, but that doesn't explain the error I receive. I
think the "old" factory code should remain working, no? Did I even
misunderstand/misuse the old factory?

Here's a test case that fails (when pasted into
FactorySupportFluentTestCase.cs):

                class Configuration
                {
                }

                interface IUseConfiguration
                {
                }

                class UsesConfiguration : IUseConfiguration
                {
                        public UsesConfiguration(Configuration config)
                        {
                        }
                }

                [Test]
                public void Should_resolve_factored_dependencies()
                {
                        kernel.Register(
                                Component.For<Configuration>
().LifeStyle.Singleton.UsingFactoryMethod(() => new Configuration()),
                                
Component.For<IUseConfiguration>().ImplementedBy<UsesConfiguration>
()
                                );

                        Assert.IsInstanceOf(typeof(IUseConfiguration),
kernel.Resolve<IUseConfiguration>());
                }

On 13 Jan., 03:48, John Simons <[email protected]> wrote:
> Krzysztof has done some changes to the factory facility that is
> shipped with Windsor 2.1, 
> read:http://kozmic.pl/archive/2009/12/24/castle-typed-factory-facility-reb...
>
> On Jan 13, 1:21 pm, Alexander Groß <[email protected]> wrote:
>
> > Hi,
>
> > I've tried updating my current work project to the new release and
> > found that everywhere I use the FactorySupportFacility my code breaks
> > in interesting ways. Basically it's a single FacilityException that
> > pops up.
>
> > Here's a simplified use-case:
>
> > Component.For<Configuration>()
> >     .LifeStyle.Singleton
> >     .UsingFactoryMethod(() => new Configuration(...))
>
> > Component.For<IUseTheConfiguration>()
> >     .ImplementedBy<UsesConfiguration>()
>
> > public class UsesConfiguration : IUseTheConfiguration
> > {
> >     public UsesConfiguration(Configuration config)
> >     { ... }
>
> > }
>
> > When I resolve an instance of IUseTheConfiguration the factory method
> > is first called from a GenericFactory<Configuration> that Windsor
> > provides. (I've set a breakpoint.)
>
> > After the Configuration instance is created Windsor throws an
> > exception:
> > Factory '<some guid>' (method 'TheNamespace.Configuration Create()')
> > created instance of type TheNamespace.Configuration.
> > This type is not compatible with implementation type
> > TheNamespace.UsesConfiguration registered for this component
> > (TheNamespace.UsesConfiguration).
> > This may signify a bug. If it's the expected behavior, change the
> > registration of this component to cover this return type.
>
> > The exception is thrown from FactoryActivator.Instantiate(), actually
> > at the latest possible point before returning the factored
> > Configuration instance. I suspect it is typeof
> > (UsesConfiguration).IsInstanceOfType(Configuration) that returns
> > false.
>
> > Any ideas what's wrong with my code?
>
> > Thanks,
> > Alex
>
>
-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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-users?hl=en.


Reply via email to