如何在.NET中使用沙箱创建一个插件模型? [英] How to create a Plugin Model in .NET with Sandbox?

查看:487
本文介绍了如何在.NET中使用沙箱创建一个插件模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来加载.NET程序集到一个沙盒环境,也被限制在自定义的方法吗?我知道你可以在不同的AppDomain运行大会,但您无法做到这一点,你要限制某些东西限制它?

Is there a way to load a .NET Assembly into a Sandbox environment that is also restricted in custom ways? I know you can run an Assembly in a different AppDomain, but can you limit it from being able to do certain things that you want to restrict?

例如:我希望能够加载了一个插件(简单,通过一个特定的接口只是定义)的ASP.NET应用程序中的一个单独组件内,但我只希望插件能够访问某些数据访问层组分和不能够直接连接到任何数据库。我想有一个单一的应用程序实例托管多个客户端的数据的情况下,我只希望插件能够访问的数据为当前登录特定的客户端/用户。

For example: I want to be able to load up a Plugin (simple, just defined via a specific interface) within a separate Assembly within an ASP.NET application, but I only want the plugin to be able to access certain Data Access Layer component and not be able to connect to any databases directly. I'm thinking about the scenario of having a single application instance hosting multiple clients data, and I only want the plugin to be able to access the data for the specific client/user that is currently logged in.

人对如何做到这一点任何想法?

Anyone have any ideas on how to do this?

我发现了以下问题在这里等如何加载大会在沙箱中,但它并没有谈论添加沙盒中的任何自定义的限制:

I found the following question here on SO on how to load an Assembly in a Sandbox, but it doesn't talk about adding any custom restrictions of the Sandbox:

<一个href="http://stackoverflow.com/questions/510071/loading-assemblies-from-a-net-application-in-a-sandbox-environment">http://stackoverflow.com/questions/510071/loading-assemblies-from-a-net-application-in-a-sandbox-environment

更新:看起来你可以设置一个非常具体的 PermissionSet中,呼吁在 AppDomain.CreateDomain 但我不完全知道什么权限我需要设置为允许/禁止上面指定的权限。还有这篇文章在MSDN上: http://msdn.microsoft.com/en-美国/库/ bb763046.aspx

Update: It looks like you can set a very specific "PermissionSet" when calling the "AppDomain.CreateDomain", but I'm not exactly sure what permissions I'd need to set to allow/disallow the specified permission above. There's also this article on MSDN: http://msdn.microsoft.com/en-us/library/bb763046.aspx

另外,我要做到这在.NET 2.0 / 3.5

Also, I'm looking to do this in .NET 2.0/3.5

任何其他的想法,比其他System.AddIn?

Any other ideas, other than using System.AddIn?

推荐答案

您可以使用<一个href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/08/13/Build-AddIns-with-System-AddIn.aspx">System.AddIn框架(这是一个有点复杂,在我看来简单的任务),或者创建自定义的应用程序域,有什么权限需要(最低限度),你可以阅读的这里

You could use System.AddIn framework (which is a bit complicated for simpler tasks in my opinion) or create custom AppDomain, what permissions you need (minimum set), you can read here

外接程序框架一次加入3.5 AFAIR。此外,您可以谷歌可视化插件,产生存根,这使得使用该解决方案变得更加容易。

AddIn framework was added in 3.5 afair. Also, you can google to visual plugin that generates stubs, which makes using this solution much easier.

这篇关于如何在.NET中使用沙箱创建一个插件模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆