views:

120

answers:

1

I'm working on an application where third party developers will be able to write plugins. I've been looking a little at Managed Extensibility Framework and it seems the right way to go.

One thing though, I want to prevent plugins from accessing the rest of the application freely (calling singletons etc) but would want to restrict to to communicate via some interface, ideally each plugin would have to "request" permission for different things like accessing other plugins and user data, is there a good way to do accomplish this?

Only thing I can think of otherwise is to have a security string passed to each method and obfuscate the hell out of the code but it seems like an ugly solution :P

+3  A: 

What you need is a new AppDomain to be the sandbox for your plugin, but I don't think MEF supports loading exports into a separate AppDomain at this time (I'm sure someone will correct me if this is no longer the case).

If this is a serious concern for you, consider using the bits in the System.Addin namespace, and see this section on Activation, Isolation, Security, and Sandboxing for more information. It's a much more robust and secure alternative to MEF, but is far less flexible.

Update: Kent Boogaart has a blog post showing how you can use MEF and MAF together.

GraemeF