限制 Codedom 编译的程序集
我为我的应用程序编写了一个插件管理器,它利用 codedom 将 C# 代码编译到类库中并实例化其类型。 它工作得很好,现在我希望限制已编译程序集的权限。不幸的是我不知道该怎么做。 据我了解,我应该以某种方式使用 CompilerParameters.Evidence,但我不清楚如何使用。 为了清楚起见,我不想简单地将程序集分类为某个区域,我想将其限制为在插件管理器构造函数中作为参数传递的权限集。我还想提一下,我不会将程序集加载到新的 appdomin 中,它与应用程序的其余部分在同一域上执行。
谢谢。
i've written a plugin manager for my app , it utilizes codedom to compile c# code into a class library and instanciate its types.
it works perfectly , and now i wish to restrict the permissions on the compiled assembly.unfortunatly i dont know how to do so.
as far as i understand i should use CompilerParameters.Evidence in some way, but it is unclear to me of how.
for te sake of clearity , i dont wish to simply categorize the assmbly as a certain zone, i want to limit it to a permission set that is passed as an argument in the plugin managers constructor. i also would like to mention that i do not load the assembly into a new appdomin , it is executed on the same domain as the rest of the application.
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理安全性的 CodeDOM 示例对于 google 来说很棘手。经过几个小时的阅读,我发现了两种方法。
最好的似乎是托管插件框架,因为它是专为您的用例场景而设计的。
限制插件汇编代码访问
CAS(代码访问安全) 也是一种选择,但它似乎不太受欢迎并且正在退出。 中摘取的示例
这是从 [SO post][3] CAS 参考文献
.NET/Security:限制运行时加载的程序集访问某些 API
http://www.gamedev.net/community/forums/topic。 asp?topic_id=418038
http://www.go4answers.com/Example/codedom-security-64586。 ASPX
CodeDOM examples that handle security are tricky to google. After several hours of reading I have found two approaches.
The best seems to be the Managed Addin Framework because it is designed for exactly your use case senario.
Restrict plug-in assembly code access
CAS (Code Access Security) is also an option but it appears to be less popular and on the way out. Here is an example lifted from this [SO post][3]
CAS References
.NET/Security: Limiting runtime-loaded assemblies from accessing certain APIs
http://www.gamedev.net/community/forums/topic.asp?topic_id=418038
http://www.go4answers.com/Example/codedom-security-64586.aspx