The code calls the PermitOnly, Assert, or Deny method of a late-bound CodeAccessPermission object. This is not allowed for security reasons. To use the PermitOnly, Assert, and Deny methods, the variable that stores the CodeAccessPermission object must be explicitly typed (early-bound) to store only CodeAccessPermission objects.
To correct this error
Use type annotation when defining the variable that stored the CodeAccessPermission object.