Tuesday, April 24, 2007

Guidelines for using method permission requests in C#

  • Use SecurityAction.PermitOnly declarations to limit the permissions available to each method.
  • Use Security.Deny declarations to further refine the permissions available to each method.
  • Use CodeAccessPermissoin.Assert when you want to allow partially trusted code to call a method that requires permissions the caller might lack.
  • Use CodeAccessPermission.PermitOnly to imperatively reduce permissions when a section of a method requires fewer permissions than the rest of the method.
  • Use CodeAccessPermission.Demand only when your assembly implements customized functionality that does not rely on functionality built into the .Net Framework, such as calls to unmanaged code.

No comments: