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

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Feb 18 07:20:40 EST 2011



--- Comment #3 from David Schmitt <david at dasz.at> 2011-02-18 12:20:39 UTC ---
Created an attachment (id=414983)
 --> (http://bugzilla.novell.com/attachment.cgi?id=414983)
Demo app demonstrating the problem

Actually my last comment and my original analysis were wrong. The actual
problem I was experiencing comes from Type.GetType and AssemblyName.ctor using
different methods of parsing assembly names. While the latter correctly works
with unspecified versions, the former fails to do so and creates an
AssemblyName with Version= instead of an undefined version.

The important part of the attached demo app looks like this:

            // When the following two lines are removed this still works
against Microsoft, but fails under mono
            var assembly = Assembly.Load(assemblyName);
            Debug.WriteLine(String.Format("Loaded assembly [{0}]",

            var type = Type.GetType(String.Format("{0},{1}", typeName,
            Debug.WriteLine(String.Format("Loaded type     [{0}]",

Call it with typeName == "Demo2.Class" assemblyName="Demo2" (also within the
attachement, only an empty assembly). 

Assembly.Load will lead to calling mono_assembly_name_parse_full from
mono/metadata/assembly.c, which correctly sets is_version_defined depending on
whether or not the passed assemblyName contains a Version=.

If the assembly is not yet loaded, Type.GetType will lead to calling
assembly_name_to_aname from mono/metadata/reflection.c which just sets the
version part to without checking whether or not the assembly name
actually has a version set.

In the end, Assembly.Load() fails, because Version= != the Version on
the actual assembly.

This happens in 2.8, 2.10 and in master.

I can currently workaround by manually pre-loading the assemblies.

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