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
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...
Thanks
John
.m
I only got a few minutes now (going to work) but I committed a patch
with tests fixing that.
Krzysztof
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.
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
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.
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>
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.