Bug 11199 - Assembly.Load(byte[]) loads cached assemblies
Summary: Assembly.Load(byte[]) loads cached assemblies
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 11420 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-03-16 08:20 UTC by Llewellyn Pritchard
Modified: 2015-10-17 14:30 UTC (History)
5 users (show)

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


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

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. ***

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