IStackWalk.Deny 方法

定义

将导致通过调用代码传递的当前对象的每个 Demand() 失败。Causes every Demand() for the current object that passes through the calling code to fail.

public:
 void Deny();
public void Deny ();
abstract member Deny : unit -> unit
Public Sub Deny ()

注解

此方法阻止调用堆栈中较高位置的调用方通过调用此方法的代码访问受保护的资源,即使这些调用方已被授予访问该方法的权限。This method prevents callers higher in the call stack from accessing the protected resource through the code that calls this method, even if those callers have been granted permission to access it. 调用堆栈通常表示为向下增长,因此调用堆栈中较高位置的方法调用堆栈中较低的调用方法。The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack.

Deny 可以限制程序员的责任,或帮助防止意外的安全漏洞,因为这样有助于防止调用 Deny 的方法访问由拒绝的权限保护的资源。Deny can limit the liability of the programmer or help prevent accidental security vulnerabilities because it helps prevent the method that calls Deny from being used to access the resource protected by the denied permission. 如果方法对权限调用 Deny,并且调用堆栈中的调用方调用了该权限的 Demand,则该安全检查在到达 Deny时将失败。If a method calls Deny on a permission, and if a Demand for that permission is invoked by a caller lower in the call stack, that security check will fail when it reaches the Deny.

对于未授予的权限,将忽略 Deny,因为对该权限的请求将不会成功。Deny is ignored for a permission not granted because a demand for that permission will not succeed.

实施者说明

不能重写此方法。You cannot override this method.

适用于