Don t Be Afraid to Refuse Permissions
If you know that from a security viewpoint your code is limited in scope and you are concerned that your code might be used to access system resources maliciously, you can request that it never be granted specific permissions. The following example shows how you can configure an application to disallow environment access and native code access, which is otherwise known as unmanaged code:
using System; using System.IO; using System.Security; using System.Security.Permissions; [assembly:EnvironmentPermission( SecurityAction.RequestRefuse, Unrestricted = true)] [assembly:SecurityPermission( SecurityAction.RequestRefuse, UnmanagedCode = true)] namespace Perms { class ReadConfig { } }