Bug 11199 - Assembly.Load(byte[]) loads cached assemblies
Summary: Assembly.Load(byte[]) loads cached assemblies
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: master
Hardware: PC All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
: 11420 (view as bug list)
Depends on:
Reported: 2013-03-16 08:20 UTC by Llewellyn Pritchard
Modified: 2018-01-18 21:00 UTC (History)
7 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:

Compile program to reproduce (5.10 KB, application/octet-stream)
2013-03-16 08:20 UTC, Llewellyn Pritchard

Description Llewellyn Pritchard 2013-03-16 08:20:13 UTC
Created attachment 3631 [details]
Compile program to reproduce

When calling Assembly.Load(byte[]) on 2 (or more) different assemblies but with the same name, the initial assembly is loaded and cached for subsequent calls. This is different behavior than in Microsoft's implementation.

Example program:

using System;
using System.IO;
using System.Reflection;

class Program
  static void Main(string[] args)
    var class1 = File.ReadAllBytes("Class1/TestLib.dll");
    var class2 = File.ReadAllBytes("Class2/TestLib.dll");
    var ass1 = Assembly.Load(class1);
    Console.WriteLine(ass1.GetExportedTypes()[0].FullName); // should print 'TestLib.Class1'
    var ass2 = Assembly.Load(class2);
    Console.WriteLine(ass2.GetExportedTypes()[0].FullName); // should print 'TestLib.Class2'

TestLib.dll only contains 1 class depending on the subdirectory.

In the second case, Mono prints 'TestLib.Class1'.

Sample program attached.

Tested on Mono compiled from source (3.0.8).
Comment 1 Llewellyn Pritchard 2013-05-18 14:42:38 UTC
Is this ever going to be addressed or acknowlegded?
Comment 2 Rodrigo Kumpera 2013-08-23 12:42:38 UTC
We'll get to this bug at some time in the future, thanks for reporting.
Comment 3 Rodrigo Kumpera 2013-08-23 12:44:32 UTC
*** Bug 11420 has been marked as a duplicate of this bug. ***
Comment 4 Ludovic Henry 2018-01-18 21:00:10 UTC
I can reproduce with (master/117468d740a)

Note You need to log in before you can comment on or make changes to this bug.