Windsor 2.1 FactorySupportFacility

8 views
Skip to first unread message

Alexander Groß

unread,
Jan 12, 2010, 9:21:39 PM1/12/10
to Castle Project Users
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

John Simons

unread,
Jan 12, 2010, 9:48:20 PM1/12/10
to Castle Project Users
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-reborn.aspx

Alexander Groß

unread,
Jan 12, 2010, 9:58:30 PM1/12/10
to Castle Project Users
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 <johnsimons...@yahoo.com.au> 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...

John Simons

unread,
Jan 12, 2010, 10:06:41 PM1/12/10
to Castle Project Users
You may have just found the first bug in this release :(
Do you mind logging this in Donjon.

Thanks
John

Mauro Servienti

unread,
Jan 13, 2010, 12:44:22 AM1/13/10
to Castle Project Users
Same problem here.

.m

Krzysztof Koźmic

unread,
Jan 13, 2010, 2:02:36 AM1/13/10
to castle-pro...@googlegroups.com
Hey,

I only got a few minutes now (going to work) but I committed a patch
with tests fixing that.


Krzysztof

Jonathon Rossi

unread,
Jan 13, 2010, 4:52:07 AM1/13/10
to castle-pro...@googlegroups.com
Hi Alex and Mauro,

Are either of you online because I'll be releasing 2.1.1 very soon which should fix the problem, and I'd like someone to test it quickly before I push the release. Krzysztof has asked me to revert his changes today and from a week back.

2010/1/13 Krzysztof Koźmic <krzyszto...@gmail.com>
Hey,

I only got a few minutes now (going to work) but I committed a patch with tests fixing that.


Krzysztof

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.






--
Jono

Mauro Servienti

unread,
Jan 13, 2010, 5:02:11 AM1/13/10
to castle-pro...@googlegroups.com

Hi,

 

I’m online right now, if you want you can send the patch directly to me for a quick test in my environment.

 

.m

Jonathon Rossi

unread,
Jan 13, 2010, 5:04:38 AM1/13/10
to castle-pro...@googlegroups.com
Thanks. Just download the .NET 3.5 build from teamcity, don't need the one running now with Changes.txt. Build 124 contains the changes that I will release:
http://builds.castleproject.org/project.html?projectId=project19&tab=projectOverview

Cheers, Jono

Mauro Servienti

unread,
Jan 13, 2010, 5:41:00 AM1/13/10
to castle-pro...@googlegroups.com

Hi,

 

it “seems” to work as expected, I did a quick test. I currently cannot test it using the real solution that gave me the original problem because the solution is built using NHibernate that depends on a different version of Windsor and changing the Windsor version crashes NHibernate.

 

I can perform a deeper test within a few hours.

Jonathon Rossi

unread,
Jan 13, 2010, 5:57:55 AM1/13/10
to castle-pro...@googlegroups.com
OK. I'll go ahead and get the package ready to upload.

If only TeamCity didn't die again. Damn java web servers running out of memory.

Alexander Groß

unread,
Jan 13, 2010, 6:59:34 AM1/13/10
to Castle Project Users
My project's build is "green" again. Thank you for quickly fixing the
issue!

Alex

On 13 Jan., 11:57, Jonathon Rossi <j...@jonorossi.com> wrote:
> OK. I'll go ahead and get the package ready to upload.
>
> If only TeamCity didn't die again. Damn java web servers running out of
> memory.
>
> On Wed, Jan 13, 2010 at 8:41 PM, Mauro Servienti

> <mauro.servie...@gmail.com>wrote:


>
>
>
> > Hi,
>
> > it “seems” to work as expected, I did a quick test. I currently cannot test
> > it using the real solution that gave me the original problem because the
> > solution is built using NHibernate that depends on a different version of
> > Windsor and changing the Windsor version crashes NHibernate.
>
> > I can perform a deeper test within a few hours.
>
> > .m
>

> > *From:* castle-pro...@googlegroups.com [mailto:
> > castle-pro...@googlegroups.com] *On Behalf Of *Jonathon Rossi
> > *Sent:* mercoledì 13 gennaio 2010 11:05
>
> > *To:* castle-pro...@googlegroups.com
> > *Subject:* Re: Windsor 2.1 FactorySupportFacility


>
> > Thanks. Just download the .NET 3.5 build from teamcity, don't need the one
> > running now with Changes.txt. Build 124 contains the changes that I will
> > release:
>

> >http://builds.castleproject.org/project.html?projectId=project19&tab=...


>
> > Cheers, Jono
>
> > On Wed, Jan 13, 2010 at 8:02 PM, Mauro Servienti <
> > mauro.servie...@gmail.com> wrote:
>
> > Hi,
>
> > I’m online right now, if you want you can send the patch directly to me for
> > a quick test in my environment.
>
> > .m
>

> > *From:* castle-pro...@googlegroups.com [mailto:
> > castle-pro...@googlegroups.com] *On Behalf Of *Jonathon Rossi
> > *Sent:* mercoledì 13 gennaio 2010 10:52
> > *To:* castle-pro...@googlegroups.com
> > *Subject:* Re: Windsor 2.1 FactorySupportFacility


>
> > Hi Alex and Mauro,
>
> > Are either of you online because I'll be releasing 2.1.1 very soon which
> > should fix the problem, and I'd like someone to test it quickly before I
> > push the release. Krzysztof has asked me to revert his changes today and
> > from a week back.
>

> > 2010/1/13 Krzysztof Koźmic <krzysztof.koz...@gmail.com>


>
> > Hey,
>
> > I only got a few minutes now (going to work) but I committed a patch with
> > tests fixing that.
>
> > Krzysztof
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Castle Project Users" group.
> > To post to this group, send email to castle-pro...@googlegroups.com
> > .
> > To unsubscribe from this group, send email to

> > castle-project-u...@googlegroups.com<castle-project-users%2Bunsu...@googlegroups.com>


> > .
> > For more options, visit this group at
> >http://groups.google.com/group/castle-project-users?hl=en.
>
> > --
> > Jono
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Castle Project Users" group.
> > To post to this group, send email to castle-pro...@googlegroups.com
> > .
> > To unsubscribe from this group, send email to

> > castle-project-u...@googlegroups.com<castle-project-users%2Bunsu...@googlegroups.com>


> > .
> > For more options, visit this group at
> >http://groups.google.com/group/castle-project-users?hl=en.
>
> > --
> > Jono
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Castle Project Users" group.
> > To post to this group, send email to castle-pro...@googlegroups.com
> > .
> > To unsubscribe from this group, send email to

> > castle-project-u...@googlegroups.com<castle-project-users%2Bunsu...@googlegroups.com>

Jonathon Rossi

unread,
Jan 13, 2010, 7:06:17 AM1/13/10
to castle-pro...@googlegroups.com
Thanks, that is good to know.

I should have posted this in this thread too, the other one was on the development list.

Windsor 2.1.1 is now up on sf.net:
https://sourceforge.net/projects/castleproject/files/InversionOfControl/2.1/Castle-Windsor-2.1.1.zip/download

2010/1/13 Alexander Groß <agr...@therightstuff.de>
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.






--
Jono
Reply all
Reply to author
Forward
0 new messages