2007-12-06 Jb Evain <jbevain@novell.com>
[mono.git] / mono / tests / assemblyresolve_event3.cs
blobbe7d1eff8c5de6dc1037cd3523375da67781a692
1 using System;
2 using System.IO;
3 using System.Reflection;
5 class App
7 const int expected_count = 1;
8 static int event_handler_count;
10 public static int Main ()
12 AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler (MyResolveEventHandler);
14 event_handler_count = 0;
15 try {
16 Assembly a = Assembly.LoadFile (String.Format ("{0}{1}assemblyresolve{1}test{1}asm.dll", Directory.GetCurrentDirectory (), Path.DirectorySeparatorChar));
17 foreach (Type t in a.GetTypes ()) {
18 Console.WriteLine ("pp: " + t + " " + t.BaseType);
20 } catch (Exception ex) {
21 Console.WriteLine ("Caught exception: {0}", ex.Message);
22 return 1;
25 if (event_handler_count != expected_count)
26 return 2;
28 return 0;
31 static Assembly MyResolveEventHandler (object sender, ResolveEventArgs args)
33 event_handler_count++;
34 Console.WriteLine ("Resolve assembly: {0}", args.Name);
35 if (args.Name == "test, Version=0.0.0.0, Culture=neutral" || args.Name == "test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")
36 return Assembly.LoadFile (String.Format ("{0}{1}assemblyresolve{1}deps{1}test.dll", Directory.GetCurrentDirectory (), Path.DirectorySeparatorChar));
37 if (args.Name == "TestBase, Version=0.0.0.0, Culture=neutral" || args.Name == "TestBase, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")
38 return Assembly.LoadFile (String.Format ("{0}{1}assemblyresolve{1}deps{1}TestBase.dll", Directory.GetCurrentDirectory (), Path.DirectorySeparatorChar));
39 return null;