Hi Oliver, That was a bug in the documentation :). Please see it now.
@K On 10/02/2012 2:59 AM, Oliver Brandt wrote:
Hi all, I tried to replicate the according code fragment from the castle web site (http://docs.castleproject.org/(S(bcwix455ivqyod45twfzyj45))/ Windsor.Print.aspx?Page=Windsor.Whats-New-In-Windsor-3). For that I just downloaded Castle 3.0 via NuGet (09.02.2012) to be sure to have the most current version. The following code throws an exception (see end of message) when resolving the container (see act part of the test method): ------------------------------------------- 8< ----------------------------- using System; using Castle.MicroKernel.Registration; using Castle.MicroKernel.Resolvers; using Castle.Windsor; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace LazyComponentTest { [TestClass] public class LazyLoadingTests { public interface ISimpleService { string SayHelloTo(string name); } public class SimpleService : ISimpleService { public string SayHelloTo(string name) { return "Hello " + name + "!"; } } [TestMethod] public void SayHelloTo_WithLazyLoading_InstanceIsNullAfterResolving() { // Arange var container = new WindsorContainer(); container.Register( Component.For<LazyOfTComponentLoader>(), Component.For<ISimpleService>() .ImplementedBy<SimpleService>() .LifestyleTransient() ); // Act var lazy = container.Resolve<Lazy<ISimpleService>>(); // Assert Assert.IsNull(lazy); } } } ------------------------------------------- 8< ----------------------------- Does anyone have an idea? Regards Oliver ------------------------------------------- 8< ----------------------------- {"No component for supporting the service System.Lazy`1[[LazyComponentTest.LazyLoadingTests+ISimpleService, LazyComponentTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] was found"} [Castle.MicroKernel.ComponentNotFoundException]: {"No component for supporting the service System.Lazy`1[[LazyComponentTest.LazyLoadingTests+ISimpleService, LazyComponentTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] was found"} Data: {System.Collections.ListDictionaryInternal} HelpLink: "groups.google.com/group/castle-project-users" InnerException: null Message: "No component for supporting the service System.Lazy`1[[LazyComponentTest.LazyLoadingTests+ISimpleService, LazyComponentTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] was found" Source: "Castle.Windsor" StackTrace: " at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)\r\n at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments)\r\n at Castle.Windsor.WindsorContainer.Resolve[T]()\r\n at LazyComponentTest.LazyLoadingTests.SayHelloTo_WithLazyLoading_InstanceIsNullAfterResolvingAndNotNullAfterAccessingValue() in C:\\GOB1\\Source\\DependencyInjection\\LazyComponentTest\ \LazyComponentTest\\LazyLoadingTests.cs:line 41" TargetSite: {System.Object Castle.MicroKernel.IKernelInternal.Resolve(System.Type, System.Collections.IDictionary, Castle.MicroKernel.IReleasePolicy)}
-- 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.
