[System] Tweak socket test
[mono-project.git] / mono / tests / assemblyresolve_event4.cs
blobfa12f01984204dc86dd0fa9aed0f5e9b2242365d
1 using System;
2 using System.IO;
3 using System.Reflection;
5 class App
7 public static int Main ()
9 AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler (MyResolveEventHandler);
11 try {
12 var a = Assembly.Load ("test");
13 foreach (Type t in a.GetTypes ()) {
14 Console.WriteLine ("pp: " + t + " " + t.BaseType);
16 } catch (Exception ex) {
17 Console.WriteLine ("Caught exception: {0}", ex);
18 return 1;
21 return 0;
24 static Assembly MyResolveEventHandler (object sender, ResolveEventArgs args)
26 var path = Path.Combine (Directory.GetCurrentDirectory (), "assemblyresolve", "deps");
27 if (args.Name == "test" && args.RequestingAssembly == null)
28 return Assembly.LoadFile (Path.Combine (path, "test.dll"));
29 if (args.Name == "TestBase, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" && args.RequestingAssembly.GetName ().Name == "test")
30 return Assembly.LoadFile (Path.Combine (path, "TestBase.dll"));
32 throw new InvalidOperationException (String.Format ("Unexpected parameter combination {0} {1}", args.Name, args.RequestingAssembly));