This is a known and documented breaking change.

from breakingchanges.txt

change - Proxies no longer implicitly implement all interfaces of component implementation type.

impact - medium
fixability - medium

description - This original behavior was actually a bug and would produce unpredictible behavior
    for components exposing several services including their class.

fix - if you were depending on the additional non-service intrfaces being forwarded to the proxy
    specify them explicitly as addtional interfaces to proxy:
    container.Register(Component.For<CountingInterceptor>()
                        .Named("a"),
                    Component.For<ICommon>()
                        .ImplementedBy<TwoInterfacesImpl>()
                        .Interceptors("a")
                        .Proxy.AdditionalInterfaces(typeof(ICommon2))
                        .LifeStyle.Transient);


cheers,
Krzysztof

On 26/11/2011 12:01 AM, smolesen wrote:
Hi

In Windsor 2.5.3, the code below worked fine, however in Windsor 3.0
RC1 this throws the following exception:

Unable to cast object of type 'Castle.Proxies.IMyServiceProxy' to type
'IService'.

Is this a change in 3.0 ??

TIA

Søren


     public class MyInterceptor : IInterceptor
     {
         public void Intercept(IInvocation invocation)
         {
             invocation.Proceed();
         }
     }

     public class InterceptorSelector : IModelInterceptorsSelector
     {
         public bool HasInterceptors(ComponentModel model)
         {
             return
typeof(IMyService).IsAssignableFrom(model.Implementation);
         }

         public InterceptorReference[]
SelectInterceptors(ComponentModel model, InterceptorReference[]
interceptors)
         {
             if
(typeof(IMyService).IsAssignableFrom(model.Implementation))
             {
                 var tmp = new List<InterceptorReference>
{ InterceptorReference.ForType<MyInterceptor>() };
                 return tmp.ToArray();
             }
             return interceptors;
         }
     }

     public interface IService
     {

     }
     public interface IMyService
     {
         string Helloworld();
     }

     public abstract class ServiceBase : IService
     {

     }

     public class MyServiceClass : ServiceBase, IMyService
     {
         public string Helloworld()
         {
             return "Hello world";
         }
     }

     class Program
     {
         static void Main(string[] args)
         {
             var container = new WindsorContainer();
             container.Kernel.ProxyFactory.AddInterceptorSelector(new
InterceptorSelector());
             container.Register(Component.For<MyInterceptor>());

container.Register(Component.For<IMyService>().ImplementedBy<MyServiceClass>().Named("testService"));
             var sut = container.Resolve<IService>("testService");

             var res = ((IMyService)sut).Helloworld();
         }
     }


--
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.

Reply via email to