Declarative security does which one of the following?
-
It sets the permissions on any value types that are declared.
-
It configures the machine's system security policy.
-
It is implemented by code and does not use attributes.
-
It uses attributes to place security information into the metadata of your code.
-
It sets the permissions on any reference types that are declared.
Declarative security uses attributes (like [PrincipalPermission]) embedded in code metadata to declare security requirements at compile time. This contrasts with imperative security, which uses runtime code to perform security checks. Declarative security is more maintainable and can be inspected via tools.
Declarative security in .NET is expressed using attributes placed directly in code, which the compiler embeds into the assembly's metadata; this lets the CLR enforce permission checks (like requiring a specific permission before a method runs) without the developer writing imperative permission-checking code.