Support of interception in Silverlight

Jul 8, 2009 at 7:33 AM


When are you planning to release Silverlight unity version that supports interception?


Alexey Zakharov.

Aug 8, 2009 at 8:34 AM

+1 for interception. Could really use this.


Aug 14, 2009 at 9:40 PM

Alexey, Thomas,

There is no interception story in the planned Unity 2.0 for Silverlight release. You can see our product backlog at

During our initial planning and consultation with the Advisory Board and the community, this story didn't come up. However, I am adding it to the list for consideration after Unity 2.0 ships.


Enterprise Library/Unity Product Owner

Aug 15, 2009 at 10:40 AM


Thanks for the reply Grigori.


Oct 19, 2009 at 7:35 AM

Yes! We need Interception in Silverlight 3, too. It's very easy way of implementing security.

Make it quickly, pleeeease :)

Thx in advance for adding to list. Maybe it can be pushed earler?

Pawel Borkowski

Jun 7, 2010 at 1:51 PM

Hi - is there anything new in this issue?

are you guys going to support soon?


Aug 10, 2010 at 7:35 PM
Any update on this? I was hoping to use Interception in a new Silverlight project I'm working on but quickly discovered its not supported yet. (Using SL4 and Prism 4)
Aug 10, 2010 at 7:56 PM

Thanks all for your enthusiasm re: using Unity in Silverlight apps.

Transparent proxy interception won't work, but the codegen-based interception may work. We have this interception story in our backlog.  Once we open voting on stories for EntLib for Silverlight, please make sure to participate. There will be an invite with the link on the front page of the codeplex site.



Aug 10, 2010 at 8:10 PM
Thanks for a very quick reply Grigori. Much appreciated. I'm using Unity for DI already and a Container Configured Interception is what I was looking for, either using Interface or Virtual Method Interceptor. Any idea when the voting will take place, ( this year, next year, next decade :) )
Aug 10, 2010 at 8:17 PM

Yes, those are the two interceptors I was talking about. I plan voting to take place this fall.

Beside interceptors, any other suggestions re:Unity for SL?

Aug 10, 2010 at 8:53 PM
Edited Aug 10, 2010 at 10:09 PM

I have been trying to figure out how to use Unity to resolve objects by role, where the resulting target object can inherit from different interfaces depending on the role. Typically you would have one interface type per role. Currently you can have multiple mappings per interface by registering type and name, like this:

// Create container and register types
myContainer.RegisterType<IMyService, DataService>("Data");
myContainer.RegisterType<IMyService, LoggingServic>("Logging");

// Retrieve an instance of each type
IMyService myDataService = myContainer.Resolve<IMyService>("Data");
IMyService myLoggingService = myContainer.Resolve<IMyService>("Logging");

but what I am looking for is something like this:

// Create container and register types
myContainer.RegisterTypeByRole<TypeOf(MyObject), IDataStore, MyObjectDataStore>("DataStore");
myContainer.RegisterTypeByRole<TypeOf(MyObject), IEditor, MyObjectEditor>("Editor");

// Retrieve an instance by role, where the source object has already been instantiated.
IDataStore dataStore = myContainer.ResolveByRole(objectInstance, "DataStore"):
IEditor editor = myContainer.ResolveByRole(objectInstance, "Editor");

Can this be done somehow?


Aug 11, 2010 at 4:39 AM

I'm not sure I understand what you want the container doing in the ResolveByRole method. Isn't it just a cast at that point? Could you provide the code you'd want assuming you don't have the container? What do you do now to get this functionality?

Aug 11, 2010 at 2:47 PM

I have my own factory pattern I initially implemented in Delphi many years ago, way before the initial release of dotNet in 2002. This pattern has stayed with me ever since and I now want to incorporate that into my next project but using Unity. I was pretty sure this could be done in Unity and I think I finally figured it out this morning and honestly should have days ago. I guess I just needed to ask the question somewhere to get my mind in gear.

This should do the trick.

// Register types
myContainer.RegisterType<IDataStore, MyObjectDataStore>(typeof(MyObject).Name);
myContainer.RegisterType<IEditor, MyObjectEditor>(typeof(MyObject).Name);

// Resolve by type and name.
IDataStore dataStore = myContainer.Resolve<IDataStore>(MyObject.GetType().Name);
IEditor editor = myContainer.Resolve<IEditor>(MyObject.GetType().Name);

Thanks for the help :)

Sep 7, 2010 at 8:38 AM

Hi all,

I also desperately need Interception for SilverLight. Already using Unity + Interception for WPF development, working like a charm. Would need it for SilverLight too. So I am in for voting for it. 

Kind Regards


Mar 7, 2011 at 10:20 PM

We've posted our first drop of Unity Interception for Silverlight. Take a look, provide feedback!