.NET 信任级别问题
是否可以对项目进行更改,从而导致其程序集在不同的信任级别中执行?如果是的话,那是什么?
据我了解,这只能在项目本身之外确定......
Is it possible to make a change to a project that will cause it's assembly to be executed in a different trust level? If so what is it?
From what I understand this can only be determined form outside of the project itself...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为直接通过项目设置不可能做到这一点。但您可以尝试利用项目中的应用程序域。这意味着您必须更改程序的代码,所以我不确定您是否同意。
借助 appdomains ,您可以为每个程序集创建小沙箱,并在沙箱内运行程序集。对于每个应用程序域,您可以使用 AppDomain.CreateDomain 中的参数更改其权限集-方法。这是 David DeWinter 在 “如何托管部分信任沙箱”。
您还可以使用 .NET Framework 配置工具来调整程序集的信任级别或 caspol 以给予其完全信任。但这些是在您的项目之外控制的。
I don't think this is possible directly through the project's settings. But you could try to leverage the application domains in your project. This means that you have to change your program's code so I'm not sure if that's OK with you.
With the help of appdomains, you can create little sandboxes for each of your assemblies and run the assemblies inside their sandboxes. For every appdomain, you can change their permission sets by using the parameters in AppDomain.CreateDomain-method. Here's a good tutorial by David DeWinter on "How to Host a Partial Trust Sandbox".
Also you can use the .NET Framework Configuration tool to adjust the assembly's trust level or the caspol to give it the full trust. But these are controlled outside your project.