Assembly: mscorlib (in mscorlib.dll)
There is already an active Deny for the current frame.
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 Deny is effective until the calling code returns to its caller. Only one Deny can be active on a frame. An attempt to call Deny when an active Deny exists on the frame results in a SecurityException. Call RevertDeny or RevertAll to remove an active Deny. Deny is ignored for a permission not granted because a demand for that permission will not succeed.Notes to Inheritors You cannot override this method.
The following code example shows the use of the Deny method to prevent access to the resource specified by the current instance. This code example is part of a larger example provided for the RevertAll method.
// Create a new UIPermission that allows access only to OwnClipboard. UIPermission^ clipboardPermission = gcnew UIPermission( UIPermissionClipboard::OwnClipboard ); // Deny access to OwnClipboard. Console::WriteLine( L"Denying access to OwnClipboard" ); clipboardPermission->Deny(); // Demand access to files in the specified path. DemandOwnClipboardAccess(); // Revert the Deny. Console::WriteLine( L"Reverting the Deny." ); CodeAccessPermission::RevertDeny(); DemandOwnClipboardAccess();
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.