[xbuild] Add support for Before/AfterTargets.
[mono.git] / mono / tests / appdomain-unload.cs
index c066037b9e7b84c3bd18c25474344dc5ef08d059..c811eec33676834d4ce737fd0434385a9ce6987e 100644 (file)
@@ -1,6 +1,7 @@
 using System;
 using System.Threading;
 using System.Reflection;
+using System.Runtime.Remoting;
 
 [Serializable]
 public class Foo {
@@ -10,6 +11,13 @@ public class Foo {
        }
 }
 
+public class Bar : MarshalByRefObject {
+       public int test (int x) {
+               Console.WriteLine ("in " + Thread.GetDomain ().FriendlyName);
+               return x + 1;
+       }
+}
+
 [Serializable]
 public class SlowFinalize {
 
@@ -89,8 +97,8 @@ class CrossDomainTester : MarshalByRefObject
 
 public class Tests
 {
-       public static int Main() {
-               return TestDriver.RunTests (typeof (Tests));
+       public static int Main(string[] args) {
+               return TestDriver.RunTests (typeof (Tests), args);
        }
 
        public static int test_0_unload () {
@@ -234,6 +242,26 @@ public class Tests
                return 0;
        }
 
+       public static int test_0_invoke_after_unload () {
+               AppDomain domain = AppDomain.CreateDomain ("DeadInvokeTest");
+               Bar bar = (Bar)domain.CreateInstanceAndUnwrap (typeof (Tests).Assembly.FullName, "Bar");
+               int x;
+
+               if (!RemotingServices.IsTransparentProxy(bar))
+                       return 3;
+
+               AppDomain.Unload (domain);
+
+               try {
+                       x = bar.test (123);
+                       if (x == 124)
+                               return 1;
+                       return 2;
+               } catch (Exception e) {
+                       return 0;
+               }
+       }
+
        // FIXME: This does not work yet, because the thread is finalized too
        // early
        /*