Assume a .NET class library code that, for example, writes to the Windows registry. Then this code has problem to run over internet, because default Internet policy does not give access to write to the registry.
By adding a RequestMinimum
statement in the assembly we can specify that the code requires permission to write to write to the registry. This will not alter the fact that the code does not have the permission, but will stop the assembly from loading; the runtime will throw a System.Security.Policy.PolicyException
and identify the permission that is required.
Do you now any other examples of using evidence, security policy and permissions (the key elements of code-access security) to prevent an assembly from loading on a web server?