Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Método CodeAccessPermission.Deny ()

 

Publicado: octubre de 2016

Nota: Esta API ahora está obsoleta.

Impide que los autores de la llamada situados en la posición más alta de la pila de llamadas usen el código que llama a este método para tener acceso al recurso especificado por la instancia actual.

Espacio de nombres:   System.Security
Ensamblado:  mscorlib (en mscorlib.dll)

<ObsoleteAttribute("Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>
Public Sub Deny

Exception Condition
SecurityException

Ya hay una Deny activa para el fotograma actual.

System_CAPS_importantImportante

The M:System.Security.CodeAccessPermission.Deny method should be used only to protect resources from accidental access by fully trusted code. It should not be used to protect resources from intentional misuse by untrusted code. For example, if method A issues a M:System.Security.CodeAccessPermission.Deny for a permission and then calls method B, method B can overtly override the M:System.Security.CodeAccessPermission.Deny by issuing an M:System.Security.CodeAccessPermission.Assert. The called method is always higher in the stack. Therefore, if method B tries to access a protected resource, the security system begins checking for permissions with it because method B is the immediate caller, and then walks down the stack to confirm that there is no M:System.Security.CodeAccessPermission.Deny or M:System.Security.CodeAccessPermission.PermitOnly lower in the stack. Method B, which is trying to access the resource, can stop the stack walk immediately by using the M:System.Security.CodeAccessPermission.Assert method. In that case, the M:System.Security.CodeAccessPermission.Deny placed on the stack by method A (the calling method) is never discovered.

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 can limit the liability of the programmer or help prevent accidental security issues because it helps prevent the method that calls Deny from being used to access the resource protected by the denied permission. 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.

The call to M:System.Security.CodeAccessPermission.Deny is effective until the calling code returns to its caller. Only one M:System.Security.CodeAccessPermission.Deny can be active on a frame. An attempt to call M:System.Security.CodeAccessPermission.Deny when an active M:System.Security.CodeAccessPermission.Deny exists on the frame results in a T:System.Security.SecurityException. Call M:System.Security.CodeAccessPermission.RevertDeny or M:System.Security.CodeAccessPermission.RevertAll to remove an active M:System.Security.CodeAccessPermission.Deny. M:System.Security.CodeAccessPermission.Deny is ignored for a permission not granted because a demand for that permission will not succeed.

Notas para desarrolladores de herederos:

You cannot override this method.

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar: