.Net security allows code to use protected resources only if it has "permission" to do so.
To express this, .NET uses the concept of permissions, which represents the right to code to access protected resources. Code requests the permissions it needs, and the security policy applied by .NET determines which permissions the code is actually granted.
.NET provides code access permission classes. Each of these classes encapsulates the ability to access a particular resource. You use these permissions to indicate to ..NET what your code needs to be allowed to do and to indicate what your code caller's must be authorized to.
POLICY ALSO USES THESE OBJECTS TO DETERMINE WHAT PERMISSIONS TO GRANT TO CODE.
Policy Enforcement of security policy is what makes..NET managed code safe. Every assembly that loads is subject to security policy that grants code permissions based on trust, with trust based on evidence about the code.
There are two ways to modify security permissions in C# by using calls to permission classes in the .NET frameworks, or by using security permission attributes.
The .NET security system prevents malicious code downloaded from the network from damaging your computer. However, these security checks are not without cost, even if your code never throws a security exception.
You can disable the unmanaged code security demand when making calls to unmanaged code by using the SuppressUnmanagedCodeSecurity attribute.