merged Sys.Web.Services 2.0 support in my branch:
[mono.git] / mono / tests / cas / linkdemand / cas7.cs
1 using System;
2 using System.Security;
3 using System.Security.Permissions;
4
5 [assembly: SecurityPermission (SecurityAction.RequestRefuse, ControlPrincipal=true)]
6
7 public delegate int MyReturnCode (int rc);
8
9 public class Program {
10
11         [SecurityPermission (SecurityAction.LinkDemand, ControlPrincipal=true)]
12         public int InstanceTest (int rc)
13         {
14                 Console.WriteLine ("*1* Instance delegate call expected to fail!");
15                 return rc;
16         }
17
18         static int Test ()
19         {
20                 Program p = new Program ();
21                 MyReturnCode rc = new MyReturnCode (p.InstanceTest);
22                 return rc (1);
23         }
24
25         static int Main ()
26         {
27                 try {
28                         return Test ();
29                 }
30                 catch (SecurityException se) {
31                         Console.WriteLine ("*0* Expected SecurityException\n{0}", se);
32                         return 0;
33                 }
34                 catch (Exception e) {
35                         Console.WriteLine ("*2* Unexpected Exception\n{0}", e);
36                         return 2;
37                 }
38         }
39 }