using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security; using System.Security.Permissions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Trust_Test { class Program { #region Demand //static void Main(string[] args) //{ // string sFile = @"C:\data.txt"; // CodeAccessPermission cap = new FileIOPermission(FileIOPermissionAccess.Read, sFile); // try // { // cap.Demand(); // } // catch (SecurityException e) // { // } //} #endregion #region Deny_RevertDeny //static void Main() //{ // PermissionSet ps = new PermissionSet(PermissionState.None); // ps.AddPermission((new FileIOPermission(FileIOPermissionAccess.AllAccess, @"C:\WINDOWS"))); // ps.AddPermission(new RegistryPermission(RegistryPermissionAccess.AllAccess, string.Empty)); // ps.Deny(); // CodeAccessPermission.RevertDeny(); //} #endregion #region Assert_RevertAssert static void Main() { CodeAccessPermission cap = new RegistryPermission(RegistryPermissionAccess.NoAccess, string.Empty); cap.Assert(); RegistryPermission.RevertAssert(); } #endregion } }