3 using System
.Reflection
;
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;
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
);
25 if (event_handler_count
!= expected_count
)
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
));