I'm creating a web-related application and I want to add plugin support to it. But I want the plugin dlls to be restricted from everything except my SaveSettings(), RequestPage() and SendToHost() methods. Any good examples how to do that?
Asked
Active
Viewed 565 times
1 Answers
0
You can require your plugins to implement an interface which contains those three methods. In your code then you would call those methods where it is necessary to apply the plugin functionality.
Of course this will not prevent them from executing code within those methods that is not desirable. This becomes more of a security problem in this case. I can't think of a straightforward way of doing this except to load the plugin assemblies into another AppDomain and set security restrictions on the AppDomain about what they can do. This will also of course complicate how you pass data between your plugin and your code.

Can Gencer
- 8,822
- 5
- 33
- 52
-
That's exactly what I want to do. But I couldn't find good examples of that. – blez Mar 06 '11 at 14:48
-
-
I can create new appdomain and create an inteface, but I don't know how to restrict it. – blez Mar 06 '11 at 15:00
-
2Here is an example on how to do it : http://stackoverflow.com/questions/4145713/looking-for-a-practical-approach-to-sandboxing-net-plugins – Can Gencer Mar 06 '11 at 15:02
-
-