Establishes security policy level for application domain.
using System; using System.Threading; using System.Security; using System.Security.Policy; using System.Security.Permissions; class MainClass { static void Main(string[] args) { AppDomain domain = System.AppDomain.CreateDomain("MyDomain"); PolicyLevel polLevel = PolicyLevel.CreateAppDomainLevel(); PermissionSet permSet = new PermissionSet(PermissionState.None); permSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); polLevel.RootCodeGroup.PolicyStatement = new PolicyStatement(permSet); domain.SetAppDomainPolicy(polLevel); domain.ExecuteAssembly("Assemblies\\MyWindowsExe.exe"); AppDomain.Unload(domain); } }