[runtime] Overwrite stacktrace for exception on re-throw. Fixes #1856.
[mono.git] / mono / tests / cas / demand / sucs3.cs
1 using System;
2 using System.Runtime.InteropServices;
3 using System.Security;
4 using System.Security.Permissions;
5
6 public class Program {
7
8         // for Mono
9         [DllImport ("libc", SetLastError=true)]
10         [SuppressUnmanagedCodeSecurity]
11         public static extern uint getuid ();
12
13         // for Microsoft
14         [DllImport ("kernel32.dll", SetLastError=true)]
15         [SuppressUnmanagedCodeSecurity]
16         public static extern uint GetTickCount ();
17
18         static bool RunningOnMono ()
19         {
20                 bool mono = (Type.GetType ("Mono.Math.BigInteger") != null); 
21                 Console.WriteLine ("Running on {0} runtime...", mono ? "Mono" : "Microsoft");
22                 return mono;
23         }
24
25         static int Test ()
26         {
27                 try {
28                         uint u = (RunningOnMono ()) ? getuid () : GetTickCount ();
29                         Console.WriteLine ("*0* P/Invoke: {0}", u);
30                         return 0;
31                 }
32                 catch (SecurityException se) {
33                         Console.WriteLine ("*1* Unexpected SecurityException\n{0}", se);
34                         return 1;
35                 }
36                 catch (Exception e) {
37                         Console.WriteLine ("*2* Unexpected exception\n{0}", e);
38                         return 2;
39                 }
40         }
41
42         [SecurityPermission (SecurityAction.Deny, UnmanagedCode=true)]
43         static int Main ()
44         {
45                 return Test ();
46         }
47 }