Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / bug-36848.cs
1 // Load an interface from an invalid DLL and ensure the failure is clean.
2 // Notice this is very similar to bug-81673, except the interface is loaded
3 // through a transparent proxy instead of directly.
4
5 using System;
6 using System.Runtime.Remoting;
7 using System.Runtime.Remoting.Proxies;
8 using System.Runtime.Remoting.Messaging;
9
10 namespace Application
11 {
12         public class App
13         {
14                 public static void Test ()
15                 {
16                 RemoteProxy remote2 = new RemoteProxy (typeof(App).Assembly.GetType("Application.Remote"));
17                 remote2.GetTransparentProxy ();
18                 }
19
20                 public static int Main ()
21                 {
22                         int numCaught = 0;
23
24                         for (int i = 0; i < 10; ++i) {
25                                 try {
26                                         Test ();
27                                 } catch (Exception) {
28                                         ++numCaught;
29                                 }
30                         }
31                         if (numCaught == 10)
32                                 return 0;
33                         return 1;
34                 }
35         }
36
37         class Remote : MarshalByRefObject, IMyInterface {
38                 public void Run ()
39                 {
40                 }
41         }
42
43         class RemoteProxy : RealProxy {
44                 public RemoteProxy (Type t) : base (t) {
45
46                 }
47
48                 public override IMessage Invoke (IMessage request) {
49                         return null;
50                 }
51         }
52 }