Specifies that only the resources described by the current instance can be accessed by calling code, even if the code has been granted permission to access other resources.
Type Reason System.Security.SecurityException A previous call to PermitOnly has already set the permissions for the current stack frame.
Note:PermissionSet.PermitOnly is similar to PermissionSet.Deny in that both methods cause access to fail where it might otherwise succeed. The difference is that PermissionSet.Deny specifies permissions for which to refuse access, while PermissionSet.PermitOnly specifies the only permissions that will succeed.
This is the only way to permit multiple permissions at the same time within a stack frame because only a single permit at a time can be active on a frame; subsequent permits will result in an exception.
Operation
Callers are required to be prevented from accessing resources not secured by the contents of the current instance, even if a caller has been granted permission to access such resources.
A PermissionSet.PermitOnly is in effect until the calling code returns to its caller.
Usage
Use this method to limit access to a specified set of resources.
Namespace: System.Security
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0