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::Assert ()

 

Publicado: octubre de 2016

Declara que el código de llamada puede tener acceso al recurso protegido por una demanda de permiso a través del código que llama a este método, incluso si los autores de la llamada situados en una posición más alta de la pila no tienen permiso para tener acceso al recurso. El uso de Assert puede crear problemas de seguridad.

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

public:
virtual void Assert() sealed

Exception Condition
SecurityException

El código de llamada no tiene SecurityPermissionFlag::Assertion.

O bien

Ya hay una Assert activa para el marco actual.

The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack. Calling M:System.Security.CodeAccessPermission.Assert prevents a stack walk originating lower in the call stack from proceeding up the call stack beyond the code that calls this method. Therefore, even if callers higher on the call stack do not have the requisite permissions to access a resource, they can still access it through the code that calls this method on the necessary permission. An assertion is effective only if the code that calls M:System.Security.CodeAccessPermission.Assert passes the security check for the permission that it is asserting.

The call to M:System.Security.CodeAccessPermission.Assert is effective until the calling code returns to its caller. Only one M:System.Security.CodeAccessPermission.Assert can be active on a frame. An attempt to call M:System.Security.CodeAccessPermission.Assert when an active M:System.Security.CodeAccessPermission.Assert exists on the frame results in a T:System.Security.SecurityException. Call M:System.Security.CodeAccessPermission.RevertAssert or M:System.Security.CodeAccessPermission.RevertAll to remove an active M:System.Security.CodeAccessPermission.Assert.

Assert is ignored for a permission not granted because a demand for that permission will not succeed. However, if code lower on the call stack calls Demand for that permission, a SecurityException is thrown when the stack walk reaches the code that tried to call Assert. This happens because the code that called Assert has not been granted the permission, even though it tried to Assert it.

System_CAPS_cautionPrecaución

Because calling M:System.Security.CodeAccessPermission.Assert removes the requirement that all code in the call chain must be granted permission to access the specified resource, it can open up security issues if used incorrectly or inappropriately. Therefore, it should be used with great caution.

Notas para desarrolladores de herederos:

You cannot override this method.

SecurityPermission

for the ability to call M:System.Security.CodeAccessPermission.Assert. Associated enumeration: F:System.Security.Permissions.SecurityPermissionFlag.Assertion

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar: