经过大量搜索后,我偶然发现了 CLR 团队的这篇博客文章,它不仅证实了 CAS 将在 .NET 4 中消失,而且还提供了一个很好的指南,说明什么会破坏以及如何迁移到新的沙盒模型:新安全模型: 转向更好的沙盒。来自文章:
在 v4 之前的 .Net Framework 版本中,我们有很多方法来限制程序集的权限,甚至是程序集中的某些代码路径:
Stack-walk 修饰符:Deny、PermitOnly
程序集级请求:RequestOptional、RequestRefuse、RequestMinimum
策略更改:caspol 和 AppDomain.SetPolicyLevel
Loading an assembly with a Zone other than MyComputer
In the past, these APIs have been a
source of confusion for host and
application writers. In .Net Framework
4, these methods of restricting
permissions are marked obsolete and we
hope to remove them at a point in the
future.
Most distressing is the fact that all these deprecated methods of creating a sandbox will start throwing a NotSupportedException
. This is exceptionally precarious for any poor souls (like myself) that for whatever reason are required to implement CAS in their organization at this time. You have been warned.