linux-packaging-mono/mono/tests/assemblyresolve_event4.cs
Xamarin Public Jenkins (auto-signing) 536cd135cc Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
2017-08-21 15:34:15 +00:00

34 lines
1.1 KiB
C#

using System;
using System.IO;
using System.Reflection;
class App
{
public static int Main ()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler (MyResolveEventHandler);
try {
var a = Assembly.Load ("Test");
foreach (Type t in a.GetTypes ()) {
Console.WriteLine ("pp: " + t + " " + t.BaseType);
}
} catch (Exception ex) {
Console.WriteLine ("Caught exception: {0}", ex);
return 1;
}
return 0;
}
static Assembly MyResolveEventHandler (object sender, ResolveEventArgs args)
{
if (args.Name == "Test" && args.RequestingAssembly == null)
return Assembly.LoadFile (Path.Combine (Directory.GetCurrentDirectory (), "assemblyresolve_deps", "Test.dll"));
if (args.Name == "TestBase, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" && args.RequestingAssembly.GetName ().Name == "Test")
return Assembly.LoadFile (Path.Combine (Directory.GetCurrentDirectory (), "assemblyresolve_deps", "TestBase.dll"));
throw new InvalidOperationException (String.Format ("Unexpected parameter combination Name=\"{0}\" RequestingAssembly=\"{1}\"", args.Name, args.RequestingAssembly));
}
}