PermissionSet.RemovePermission(Type) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从集中删除某一类型的权限。
public:
System::Security::IPermission ^ RemovePermission(Type ^ permClass);
public:
virtual System::Security::IPermission ^ RemovePermission(Type ^ permClass);
public System.Security.IPermission RemovePermission (Type permClass);
public System.Security.IPermission? RemovePermission (Type? permClass);
public virtual System.Security.IPermission RemovePermission (Type permClass);
member this.RemovePermission : Type -> System.Security.IPermission
abstract member RemovePermission : Type -> System.Security.IPermission
override this.RemovePermission : Type -> System.Security.IPermission
Public Function RemovePermission (permClass As Type) As IPermission
Public Overridable Function RemovePermission (permClass As Type) As IPermission
参数
- permClass
- Type
要删除的权限类型。
返回
从集中删除了的权限。
例外
示例
下面的代码示例演示如何使用 RemovePermission 该方法从权限集中删除 a FileIOPermission 。 此代码示例是为 PermissionSet 类提供的一个更大示例的一部分。
// Remove FileIOPermission from the permission set.
ps5->RemovePermission( FileIOPermission::typeid );
Console::WriteLine( "The last permission set after removing FileIOPermission = {0}", ps5 );
// Remove FileIOPermission from the permission set.
ps5.RemovePermission(typeof(FileIOPermission));
Console.WriteLine("The last permission set after removing FileIOPermission = "
+ ps5.ToString());
' Remove FileIOPermission from the permission set.
ps5.RemovePermission(GetType(FileIOPermission))
Console.WriteLine("The last permission set after removing FileIOPermission = " & ps5.ToString())
注解
重要
不能从不受限制的权限集中删除权限。 尝试删除权限后,权限集将保持不受限制,并且不会引发异常。
以下 C# 代码尝试从FullTrust
权限集中删除FileIOPermission,但不会删除该权限。
PolicyLevel myPol = PolicyLevel.CreateAppDomainLevel();
PermissionSet myPermSet = myPol.GetNamedPermissionSet("FullTrust");
myPermSet.RemovePermission(typeof(FileIOPermission));
继承者说明
从PermissionSet中继承时,可以通过重写RemovePermissionImpl(Type)方法来更改方法的行为RemovePermission(Type)。