Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Método CodeAccessPermission.Assert ()

 

Declara que o código de chamada pode acessar o recurso protegido por uma demanda de permissão através do código que chama este método, mesmo que os chamadores na pilha não tenham recebido permissão para acessar o recurso. Usar Assert pode criar problemas de segurança.

Namespace:   System.Security
Assembly:  mscorlib (em mscorlib.dll)

public void Assert()

Exception Condition
SecurityException

O código de chamada não tem SecurityPermissionFlag.Assertion.

-ou-

Já existe um Assert ativo para o quadro atual.

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_cautionCuidado

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.

Observações para os Herdeiros:

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
Disponível desde 1.1
Retornar ao início
Mostrar: