[Mono-bugs] [Bug 499013] New: Appdomain.GetAssemblies() returns assemblies loaded for reflection only, not just for execution. Different behaviour than .NET

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 28 17:57:24 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=499013


           Summary: Appdomain.GetAssemblies() returns assemblies loaded
                    for reflection only, not just for execution. Different
                    behaviour than .NET
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: i686
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jonas.larsson at manodo.se
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.9)
Gecko/2009042113 Ubuntu/9.04 (jaunty) Firefox/3.0.9

When calling Appdomain.GetAssemblies() one should get an array with all
assemblies currently loaded in execution context.

See
http://msdn.microsoft.com/en-us/library/system.appdomain.getassemblies.aspx

"Gets the assemblies that have been loaded into the execution context of this
application domain."

Mono 2.4 release tarball does not follow this.

Simple test program to run under .net and mono
-------------
using System;

using System.Reflection;



class GetAssembliesBug

{

    static void Main(string[] args)

    {

        Console.Out.WriteLine("Loaded in execution context: {0}",
AppDomain.CurrentDomain.GetAssemblies().Length);

        Console.Out.WriteLine("Loaded in reflection context: {0}",
AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().Length);



        Assembly loaded =
Assembly.ReflectionOnlyLoad(typeof(System.Data.SqlDbType).Assembly.FullName);



        Console.Out.WriteLine("Loaded in execution context: {0}",
AppDomain.CurrentDomain.GetAssemblies().Length);

        foreach(Assembly a in AppDomain.CurrentDomain.GetAssemblies())

            Console.Out.WriteLine("\t{0} in {1} context", a.GetName().Name,
a.ReflectionOnly ? "reflection" : "exec");

        Console.Out.WriteLine();



        Console.Out.WriteLine("Loaded in reflection context: {0}",
AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().Length);

        foreach(Assembly a in
AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies())

            Console.Out.WriteLine("\t{0} in {1} context", a.GetName().Name,
a.ReflectionOnly ? "reflection" : "exec");



        Console.In.ReadLine();

    }

}


-----

Result in .net:

Loaded in execution context: 4
Loaded in reflection context: 0
Loaded in execution context: 4
        mscorlib in exec context
        GetAssembliesBug in exec context
        System.Data in exec context
        System in exec context

Loaded in reflection context: 1
        System.Data in reflection context

---------
Result in mono:

Loaded in execution context: 3
Loaded in reflection context: 0
Loaded in execution context: 4
    System.Data in reflection context
    System.Data in exec context
    GetAssembliesBug in exec context
    mscorlib in exec context

Loaded in reflection context: 1
    System.Data in reflection context

------
Other

I think that the bug is in
mono/mono/metadata/appdomain.c
ves_icall_System_AppDomain_GetAssemblies

Here is my patch for 2.4 branch in SVN (works for me(tm)):

Index: mono/metadata/appdomain.c
===================================================================
--- mono/metadata/appdomain.c    (revision 132563)
+++ mono/metadata/appdomain.c    (working copy)
@@ -775,6 +775,8 @@
         ass = tmp->data;
         if (refonly && !ass->ref_only)
             continue;
+        if (!refonly && ass->ref_only)
+            continue;
         if (ass->corlib_internal)
             continue;
         g_ptr_array_add (assemblies, ass);


Reproducible: Always

Steps to Reproduce:
Run supplied test program
Actual Results:  
Assemblies loaded in reflection context are returned from both GetAssemblies
and ReflectionOnlyGetAssemblies. This causes portability issues.

Expected Results:  
Assemblies should not be returned from GetAssemblies

-- 
Configure bugmail: http://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