[Mono-bugs] [Bug 661461] New: Assembly.Load(AssemblyName) doesn't work with partial names

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Dec 27 04:18:32 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=661461

https://bugzilla.novell.com/show_bug.cgi?id=661461#c0


           Summary: Assembly.Load(AssemblyName) doesn't work with partial
                    names
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: david at dasz.at
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10

Hi,

for a custom plugin loader, I'm loading assemblies from a directory with the
following code (simplified):

AssemblyName assemblyName = new AssemblyName("MyAssembly");
// search for file to load
string dllFile = LocateAssembly(assemblyName.Name);
assemblyName.CodeBase = dllFile;
return Assembly.Load(assemblyName);

This only works when the AssemblyName is fully qualified, since the checks in
mcs/class/corlib/System/AppDomain.cs::Load( do not match up with the default
values in the partial AssemblyName:

for example, the Version:

using System;

public class Test {

public static void Main(string[]args) {
        var defaultVersion = new Version();
        var allZero = new Version("0.0.0.0");

        Console.WriteLine("defaultVersion=[{0}]", defaultVersion);
        Console.WriteLine("allZero=[{0}]", allZero);
        Console.WriteLine("(defaultVersion == allZero)=[{0}]", defaultVersion
== allZero);

}

}

Produces this output (both in mono and .net):

defaultVersion=[0.0]
allZero=[0.0.0.0]
(defaultVersion == allZero)=[False]

which is sigificant, since AssemblyName initialises Version to 0.0.0.0, but the
AppDomain.Load compares against "new Version()", which has no defined build or
revision.

I manually patched the method to compare to new Version("0.0.0.0") instead, and
a similar problem cropped up when the public key token is compared, since the
partial name returns byte[0], but the Load method expects a null.





Reproducible: Always

Steps to Reproduce:
1.
2.
3.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list