Using Unity 2.0 Interception with RemoteType LifeTimeManger?

Topics: Policy Injection Application Block
Jun 11, 2010 at 2:41 PM

I have created a LifeTimeManger for remote types very similar to what is describe in this thread:  I have also implemented a IUnityContainer decorator for my client side container that attaches a policy injection interceptor for any types that have policies.  The relevant code in the decorator looks like this:


public IUnityContainer RegisterType(Type from, Type to, string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
    if (IsInjectable(from) )
        var interceptor = new Interceptor<TransparentProxyInterceptor>();
        var interceptionBehavior = new InterceptionBehavior<PolicyInjectionBehavior>();

        injectionMembers = injectionMembers == null
            ? new InjectionMember[] { interceptor, interceptionBehavior } 
            : injectionMembers.Append(interceptor,interceptionBehavior);

    return _container.RegisterType(from, to, name, lifetimeManager, injectionMembers);

This code works fine for non-remote types (the type gets wrapped in policy injection proxy if any of the matching rules in the config file apply to it.)  However, if I apply similar rules to a remote type, what gets returned is the remote type proxy with no injection proxy.  I have been digging around in the unity code and online for almost a day now with no luck on how to fix this.  Any ideas?

Jun 16, 2010 at 1:45 AM

Please post Unity questions in the Unity forum.