Vinay, Why are you using factory in the first place? As outlined by Bailey when you create component yourself you take complete control over its shape, this includes proxying it. We might add this ability you're asking for (please feel free to add this suggestion to http://castle.uservoice.com/forums/38955-windsor-v3 ) but currently it does not work like that.
Whenever possible it is advised to let the instantiation of your components to Windsor, and resort to factories only when you have no other option. As a sidenote, for static dependencies (that is dependencies known upfront like number 5 in your example) it is advised to use DependsOn, rather than DynamicParameters cheers, Krzysztof On 24 Mar, 23:29, Bailey Ling <[email protected]> wrote: > the factory facility bypasses the normal way of creating instances, so by > doing that you're basically preventing windsor from creating a proxy. what > you wanna try is use kernal.ProxyFactory and create your proxy manually > within the factory delegate/method. > > On Wed, Mar 24, 2010 at 2:38 PM, Vinay Mandy <[email protected]> wrote: > > Hello, > > > I'm having trouble with the following statement: > > > container.Register(Component.For<ISomeService>().UsingFactoryMethod(() > > => new > > > SomeServiceImpl(5)).Interceptors(InterceptorReference.ForType<SomeServiceInterceptor>()).First); > > > whenever I call the 'DoSomething' method on my resolved service, I get > > the following DP error: > > > System.NotImplementedException: This is a DynamicProxy2 error: the > > interceptor attempted to 'Proceed' for method 'Int32 > > DoSomething(Int32)' which has no target. When calling method without > > target there is no implementation to 'proceed' to and it is the > > responsibility of the interceptor to mimic the implementation (set > > return value, out arguments etc) > > > I noticed that I don't have the problem if I avoid using a factory > > method to create my service, like so: > > > container.Register(Component.For<ISomeService>().ImplementedBy<SomeServiceImpl>().DynamicParameters((kernel, > > parameters) => parameters["param"] = > > > 5).Interceptors(InterceptorReference.ForType<SomeServiceInterceptor>()).First); > > > Is there any reason that the first approach wouldn't work or is not > > suggested? Is there an alternative statement that I should use? > > > Thanks for your help > > > Vinay > > > -- > > 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]<castle-project-users%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/castle-project-users?hl=en. > > -- 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.
