This project has moved. For the latest updates, please go here.

Intercept part construction: create parts in a sandbox

Mar 9, 2011 at 9:15 AM

Hello all,

I have a particular requirement where I hope to employ MEF, but there is a problem.

I'll be deploying a system in an environment where the composable parts will come from untrusted sources, therefore I need to run the parts in a sandbox. I have all the bits I need to roll my own trivial DI framework to achieve this, but for all the usual good reasons I'd prefer to use a standard, supported framework.

So the question is: Can I intercept the call within MEF that creates the part object instances so that instead of calling the constructor in the local AppDomain I can do something like

Activator.CreateInstanceFrom(_SandboxDomain, _PartAssemblyName, _PartAssemblyClass


Thank you,


Mar 9, 2011 at 11:54 AM
Edited Mar 9, 2011 at 11:57 AM

See this previous thread.

Mar 9, 2011 at 1:22 PM

You can using the InterceptingCatalog in MEF Contrib. One of it's core design goals is to support AOP/Interception. As it is a custom catalog it works on top of MEF.

Here is a post on this:


Mar 9, 2011 at 2:52 PM

Thank you both, those are both very helpful resources.