static void Main(string[] args) { Console.WriteLine("Beginning AllFindings calls..."); ClassRequiringFullTrust.DoWork(); AccessAClassRequiringFullTrust.Access(); //Derived derived = new Derived(); //derived.TransparentInterfaceMethod(); //derived.CriticalInterfaceMethod(); //derived.CriticalVirtual(); MyBadMemberClass badMemberClass = new MyBadMemberClass(); badMemberClass.DoWork(); MyBadTypeClass myBadTypeClass = new MyBadTypeClass(); myBadTypeClass.DoWork(); }
public static void Access() { // This security check fails if the caller // does not have full trust. NamedPermissionSet pset = new NamedPermissionSet("FullTrust"); // This try-catch block shows the caller's permissions. // Correct code would either not catch the exception, // or would rethrow it. try { pset.Demand(); } catch (SecurityException e) { Console.WriteLine("Demand for full trust:{0}", e.Message); } // Call the type that requires full trust. // Violates rule AptcaMethodsShouldOnlyCallAptcaMethods. ClassRequiringFullTrust.DoWork(); }