Starting in Whidbey beta2, for Assembly.LoadFrom/LoadFile/Load(byte[]), if there is an assembly in GAC with exactly the same assembly identity, we will return the one in GAC.
ReflectionOnlyLoad and ReflectionOnlyLoadFrom APIs are not affected.
C:\>more f:\tools\fullname.csusing System;using System.IO;using System.Reflection;
class MyApp{ public static void Main(String[] argv) { if (argv.Length < 1) { Console.WriteLine("Usage: FullName assembly"); return; }
String path = Path.GetFullPath(argv[0]);
try { Console.WriteLine("Using Assembly.LoadFrom:"); Assembly a = Assembly.LoadFrom(path); AssemblyName an = a.GetName(); Console.WriteLine("FullName: " + an.FullName); Console.WriteLine("Location: " + a.Location); Console.WriteLine("Codebase: " + a.CodeBase);
Console.WriteLine(); Console.WriteLine("Using Assembly.LoadFile:"); a = Assembly.LoadFile(path); an = a.GetName(); Console.WriteLine("FullName: " + an.FullName); Console.WriteLine("Location: " + a.Location); Console.WriteLine("Codebase: " + a.CodeBase);
Console.WriteLine(); Console.WriteLine("Using Assembly.Load(byte[]):"); byte[] bytes = File.ReadAllBytes(path); a = Assembly.Load(bytes); an = a.GetName(); Console.WriteLine("FullName: " + an.FullName); Console.WriteLine("Location: " + a.Location); Console.WriteLine("Codebase: " + a.CodeBase);
Console.WriteLine(); Console.WriteLine("Using Assembly.ReflectionOnlyLoadFrom:"); a = Assembly.ReflectionOnlyLoadFrom(path); an = a.GetName(); Console.WriteLine("FullName: " + an.FullName); Console.WriteLine("Location: " + a.Location); Console.WriteLine("Codebase: " + a.CodeBase); } catch( Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }}
C:\WINDOWS\Microsoft.NET\Framework\v2.0.41101>f:\tools\fullname system.dllUsing Assembly.LoadFrom:FullName: System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Location: C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dllCodebase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
Using Assembly.LoadFile:FullName: System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Location: C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dllCodebase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
Using Assembly.Load(byte[]):FullName: System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Location: C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dllCodebase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
Using Assembly.ReflectionOnlyLoadFrom:FullName: System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Location: C:\WINDOWS\Microsoft.NET\Framework\v2.0.41101\system.dllCodebase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.41101/system.dll