JavaScript Editor Ajax toolkit     Ajax website 

Main Page

A custom attribute that inherits from CodeAccessSecurityAttribute is applied to the definition of a method, class, or assembly. This is not allowed. Dynamic security must be used instead of declarative security attributes to help control access to a portion of code.


Only early-bound code can make calls to the Assert, Deny or PermitOnly security methods within the .NET Framework. This means that type-annotated variables must be used to store permission objects, since type annotation allows the compiler to generate early-bound code. Moreover, code generated at runtime (with the eval method or with a Function object created with the new operator) is late-bound code, which prevents it from making calls to the Assert, Deny or PermitOnly methods.

In the following example, dynamic security is used to deny access to a particular file by a method.

В CopyCode imageCopy Code
import System;
import System.IO;
import System.Security;
import System.Security.Permissions;
class Alpha{
   function Bravo() {
      var fileioperm : FileIOPermission;
      fileioperm = new FileIOPermission(FileIOPermissionAccess.AllAccess, 'd:\\temp\\myfile.txt');
      // Any additional code in this method will be
      // denied access to d:\temp\myfile.txt.

To correct this error

  • Use dynamic security instead of declarative security to declare a secure method or assembly.

See Also


Troubleshooting Your Scripts

Other Resources

JScript Reference

JavaScript Editor Ajax toolkit     Ajax website