Mike, thanks for looking into this.
That's insane thought,
public WindsorContainer() : this(new DefaultKernel(), new
DefaultComponentInstaller())
{
}
This is how the default .ctor on WindsorContainer is implemented, which
is identical to your code...
I really have no idea what might be wrong. It works on all 3 machines I
have at home...
Could you step into the debugger and maybe shed some more light on
what's going on there?
Krzysztof
On 4/07/2010 3:41 PM, Mike Nichols wrote:
This test PASSES...note that I am supplying my own IKernel to the
container and now things all work just fine. Seems to indicate a
reference problem somewhere:
[Fact]
public void facility_fail()
{
IKernel kernel;
var windsorContainer = new WindsorContainer(kernel=new
DefaultKernel(),new DefaultComponentInstaller());
windsorContainer.Kernel.AddFacility<TypedFactoryFacility>();
windsorContainer.Register(Component.For<IGenericFactory>().AsFactory());
var factory = windsorContainer.Resolve<IGenericFactory>();
Assert.NotNull(factory);//PASS
var factoryHandler = kernel.GetHandler(typeof(IGenericFactory));
kernel.GetHandlers(typeof(IGenericFactory)).Length.should_be_equal_to(1);
Assert.NotNull(factoryHandler); //PASS
Assert.NotNull(kernel.Resolve<IGenericFactory>());//PASS
}
public interface IGenericFactory
{
T Create<T>();
}
On Jul 3, 10:35 pm, Mike Nichols<[email protected]> wrote:
Okay I pulled down Castle.Core/CAstle.Windsor 1.3.0.159 from Jun 3rd .
I am getting the same error as above, but check this out.
It is getting stranger. The test below fails. Note that I can resolve
the typed factory, but not the handler from the underlying Kernel,
which seems odd.
[Fact]
public void facility_fail()
{
var windsorContainer = new WindsorContainer();
windsorContainer.Kernel.AddFacility<TypedFactoryFacility>();
windsorContainer.Register(Component.For<IGenericFactory>().AsFactory());
var factory = windsorContainer.Resolve<IGenericFactory>();
Assert.NotNull(factory);//PASS
var factoryHandler =
container.Kernel.GetHandler(typeof(IGenericFactory));
Assert.NotNull(factoryHandler);//FAILS
}
public interface IGenericFactory
{
T Create<T>();
}
On Jul 3, 10:17 pm, Mike Nichols<[email protected]> wrote:
After inserting the code you requested it still fails with
exception...what is so weird is when I register on an
IWindsorContainer instance things work as expected!
I am going to pull the latest and see what happens...will post back.
[Fact]
public void facility_fail()
{
var kernel = new DefaultKernel();
kernel.AddFacility<TypedFactoryFacility>();
kernel.Register(Component.For<IGenericFactory>().AsFactory());
var factoryHandler =
kernel.GetHandler(typeof(IGenericFactory));
factoryHandler.ComponentModel.Interceptors.Count.should_be_greater_than(0);
var factory = kernel.Resolve<IGenericFactory>(); //throws
exception
}
public interface IGenericFactory
{
T Create<T>();
}
On Jul 3, 3:25 pm, Krzysztof Ko¼mic<[email protected]>
wrote:
Man, that is bizarre.
And which version are you using exactly?
Would you care to check out the latest?
Also if you could put the following code before resolve:
var factoryHandler = kernel.GetHandler(typeof(IGenericFactory));
Assert.IsGreaterThanZero(factoryHandler.ComponentModel.Interceptors.Count());
On 4/07/2010 5:57 AM, Mike Nichols wrote:
Hi Krzysztof ,
On 64bit Win 2k8 R2 server this throws an exception:
[Fact]
public void facility_fail()
{
var kernel = new DefaultKernel();
kernel.AddFacility<TypedFactoryFacility>();
kernel.Register(Component.For<IGenericFactory>().AsFactory());
var factory = kernel.Resolve<IGenericFactory>();//throws exception
(see below)
}
public interface IGenericFactory
{
T Create<T>();
}
STACK TRACE:
Castle.MicroKernel.ComponentRegistrationException: Type
Cei.MaterialsTesting.Web.Server.Specs.facility_specs+IGenericFactory
is abstract.
As such, it is not possible to instansiate it as implementation of
Cei.MaterialsTesting.Web.Server.Specs.facility_specs+IGenericFactory
service
at
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext
context, Object[] arguments, Type[] signature) in c:\TeamCity
\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel
\ComponentActivator\DefaultComponentActivator.cs: line 105
at
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\ComponentActivator
\DefaultComponentActivator.cs: line 91
at
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\ComponentActivator
\DefaultComponentActivator.cs: line 67
at
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\ComponentActivator
\AbstractComponentActivator.cs: line 75
at
Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\Lifestyle\SingletonLifestyleManager.cs:
line 48
at
Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext
context, Boolean track, Boolean instanceRequired) in c:\TeamCity
\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel
\Handlers\DefaultHandler.cs: line 66
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext
context, Boolean instanceRequired) in c:\TeamCity\buildAgent\work
\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel\Handlers
\AbstractHandler.cs: line 202
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\Handlers\AbstractHandler.cs: line 173
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler,
Type service, IDictionary additionalArguments) in c:\TeamCity
\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel
\DefaultKernel.cs: line 944
at Castle.MicroKernel.DefaultKernel.get_Item(Type service) in c:
\TeamCity\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor
\MicroKernel\DefaultKernel_Resolve.cs: line 64
at Castle.MicroKernel.DefaultKernel.Resolve(Type service) in c:
\TeamCity\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor
\MicroKernel\DefaultKernel_Resolve.cs: line 197
at Castle.MicroKernel.DefaultKernel.Resolve() in c:\TeamCity\buildAgent
\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel
\DefaultKernel_Resolve.cs: line 154
at
Cei.MaterialsTesting.Web.Server.Specs.facility_specs.facility_fail()
in facility_specs.cs: line 49
On Jul 2, 4:25 pm, Krzysztof Ko¼mic<[email protected]>
wrote:
That does not seem right. Are you sure you called .AsFactory() in the
other case as well?
Can you create a test case for that?
Krzysztof
On 3/07/2010 9:02 AM, Mike Nichols wrote:
When trying to resolve a interface-based typed factory from the kernel
(as the docs on wiki show) I get the error below using
kernel.Resolver<IUrlResolverFactory>().
When running the same code resolving from
container.Resolver<IUrlResolverFactory>() everything works as
expected.
I am running Castle.Core/Castle.Windsor from about 3 weeks ago.
Bug?
Castle.MicroKernel.ComponentRegistrationException: Type
Cei.MaterialsTesting.Web.Services.Navigation.IUrlResolverFactory is
abstract.
As such, it is not possible to instansiate it as implementation of
Cei.MaterialsTesting.Web.Services.Navigation.IUrlResolverFactory
service
at
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext
context, Object[] arguments, Type[] signature) in c:\TeamCity
\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel
\ComponentActivator\DefaultComponentActivator.cs: line 105
at
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\ComponentActivator
\DefaultComponentActivator.cs: line 91
at
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\ComponentActivator
\DefaultComponentActivator.cs: line 67
at
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\ComponentActivator
\AbstractComponentActivator.cs: line 75
at
Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\Lifestyle\AbstractLifestyleManager.cs:
line 42
at
Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext
context, Boolean track, Boolean instanceRequired) in c:\TeamCity
\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel
\Handlers\DefaultHandler.cs: line 66
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext
context, Boolean instanceRequired) in c:\TeamCity\buildAgent\work
\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel\Handlers
\AbstractHandler.cs: line 202
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext
context) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src
\Castle.Windsor\MicroKernel\Handlers\AbstractHandler.cs: line 173
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler,
Type service, IDictionary additionalArguments) in c:\TeamCity
\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel
\DefaultKernel.cs: line 944
at Castle.MicroKernel.DefaultKernel.get_Item(Type service) in c:
\TeamCity\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor
\MicroKernel\DefaultKernel_Resolve.cs: line 64
...
read more »
--
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.