Skip to content

Instantly share code, notes, and snippets.

@kumpera
Created December 6, 2013 17:32
Show Gist options
  • Select an option

  • Save kumpera/7828880 to your computer and use it in GitHub Desktop.

Select an option

Save kumpera/7828880 to your computer and use it in GitHub Desktop.
using System;
using System.Reflection;
using System.Reflection.Emit;
class Test
{
public static void Main ()
{
Assembly testAssembly = typeof (Test).Assembly;
string loadString = null;
ResolveEventHandler handler = (s,a) => {
Console.WriteLine ("------");
loadString = a.Name;
return testAssembly;
};
AppDomain.CurrentDomain.AssemblyResolve += handler;
try {
var testString = "MyDynamicType, 1.0.0.0, Culture=neutral,PublicKeyToken=0738eb9f132ed756";
// var testString = "MyDynamicType, Version=1.0.0.0, Culture=neutral,PublicKeyToken=0738eb9f132ed756";
var asm = Assembly.Load (testString);
Console.WriteLine (testString == loadString);
Console.WriteLine (testString);
Console.WriteLine (loadString);
Console.WriteLine (testAssembly == asm);
} finally {
AppDomain.CurrentDomain.AssemblyResolve -= handler;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment