2 using System.Reflection;
4 using System.Security.Permissions;
9 static void ShowStackTrace (object o, ElapsedEventArgs e)
12 Console.WriteLine ("{0}: {1}", counter, Environment.StackTrace);
15 Console.WriteLine (Assembly.GetExecutingAssembly ().Evidence.Count);
18 catch (SecurityException se) {
20 Console.WriteLine ("EXPECTED SecurityException {0}", se);
22 catch (Exception ex) {
23 Console.WriteLine ("UNEXPECTED {0}", ex);
34 static int counter = 0;
35 static int result = 0;
38 // this Deny will prevent the Assembly.Evidence property from working
39 [SecurityPermission (SecurityAction.Deny, ControlEvidence = true)]
40 static int Main (string[] args)
42 debug = (args.Length > 0);
44 SecurityManager.SecurityEnabled = (args [0] != "off");
47 if (SecurityManager.SecurityEnabled) {
48 Console.WriteLine ("SecurityManager.SecurityEnabled: true");
49 ShowStackTrace (null, null);
51 Console.WriteLine ("SecurityManager.SecurityEnabled: false");
55 t.Elapsed += new ElapsedEventHandler (ShowStackTrace);
59 System.Threading.Thread.Sleep (5000);