November 2002
Intermediate to advanced
560 pages
11h 16m
English
The CLR allows developers to express security constraints in two styles: declarative and imperative. Expressing security constraints in the declarative style means using the attribute syntax. These annotations are persisted in the metadata for the type, effectively becoming baked into the assembly at compile time. The following is an example of declarative-style security from Listing 4.4:
[PrincipalPermissionAttribute(SecurityAction.Demand,
Name=@" PROJECT42\Damien Watkins ")]
Expressing security requirements in the imperative style entails creating instances of Permission objects at runtime and invoking methods on them. The following is an example of imperative-style security from Listing 4.7:
FileIOPermission ...
Read now
Unlock full access