Ensures that only the resources specified by this permission object can be accessed, even if the code has been granted permission to access other resources.
[Visual Basic] Overridable Public Sub PermitOnly() [C#] public virtual void PermitOnly(); [C++] public: virtual void PermitOnly(); [JScript] public function PermitOnly();
Permit-only is a variant on deny, in that both cause stack walks to fail where they might otherwise succeed. The difference is that deny specifies permissions to fail stack walk on, where permit-only specifies the only permissions that are to succeed with all others failing.
A common use for permit-only is to supply a specific set of permissions that code wishes to restrict itself to, rather than specifying the permissions it has that it wants to deny. You can call this method to ensure that your code can be used to access only the resources you specify in your call(s) to PermitOnly. A permit-only is in effect until another permit-only or return from the method. Also, RevertPermitOnly or RevertAll will remove a pending permit-only.
Notes to Implementers: You cannot override this method.
CodeAccessPermission Class | CodeAccessPermission Members | System.Security Namespace