R – Setting CAS Policy

code-access-securitynet

I have a .NET application that users run from a file server. One of the .NET Assemblies requires Full Trust. I have signed the assembly. When setting the Code Access Security policy, which version of the .NET framework policy do I set? The application was built to use version 1.1 of the .NET Framework. Do I need to setup a policy for each framework?

Best Answer

You will need to set the policy on the client machine for the version of the CLR runtime used by the executing assembly. In your case, 1.1. If your application references assemblies from previous versions of .Net, they will still be loaded into the CLR version used by the main assembly. If one assembly requires full trust, a program that references it must also have full trust in order for the assembly to work correctly. This MSDN link explains it better, check out the "Walking the Stack" section: Code Access Security. Also, in case you didn't know CAS has been replaced (although not removed) as the primary means of security in .Net 4: Security Changes in the .Net Framework 4.

Regards, Drew