This patch fixes assertion failure caused by multiple ExecuteAssembly
calls for same domain. Tests are also attached. 


  Tomi.

Index: mono/metadata/object.c
===================================================================
RCS file: /mono/mono/mono/metadata/object.c,v
retrieving revision 1.112
diff -u -r1.112 object.c
--- mono/metadata/object.c	21 Aug 2002 13:04:20 -0000	1.112
+++ mono/metadata/object.c	21 Aug 2002 16:49:44 -0000
@@ -626,8 +626,8 @@
 	pa [0] = args;
 
 	domain = mono_object_domain (args);
-	g_assert (!domain->entry_assembly);
-	domain->entry_assembly = method->klass->image->assembly;
+	if (!domain->entry_assembly)
+		domain->entry_assembly = method->klass->image->assembly;
 
 	/* FIXME: check signature of method */
 	if (method->signature->ret->type == MONO_TYPE_I4) {
using System;
using System.Reflection;

class TestiMain {

        static int Main( string [] args )
        {
                System.Reflection.Assembly assembly;
                System.AppDomain otherDomain = 
System.AppDomain.CreateDomain("OtherDomain");
                otherDomain.ExecuteAssembly("AssemblyInOtherDomain.exe");
                otherDomain.ExecuteAssembly("AssemblyInOtherDomain2.exe");
                otherDomain.ExecuteAssembly("AssemblyInOtherDomain3.exe");
                
System.AppDomain.CurrentDomain.ExecuteAssembly("AssemblyInOtherDomain.exe");
                
System.AppDomain.CurrentDomain.ExecuteAssembly("AssemblyInOtherDomain2.exe");
                
System.AppDomain.CurrentDomain.ExecuteAssembly("AssemblyInOtherDomain3.exe");
                /**/
                Console.WriteLine( "From domain :" + 
System.AppDomain.CurrentDomain.ToString() );
                assembly = 
System.Reflection.Assembly.LoadFrom("AssemblyInOtherDomain.exe");
                Console.WriteLine( "Assembly: " + assembly.ToString() );
                /**/
                assembly = System.Reflection.Assembly.GetEntryAssembly();
                Console.WriteLine( assembly.GetType().ToString() );
                Console.WriteLine( "GetEntryAssembly = " + assembly.ToString() );
                return 0;
        }
}
// Output using .NET sdk.
/*
>From domain :Name: OtherDomain
There are no context policies.

GetEntryAssembly = AssemblyInOtherDomain, Version=0.0.0.0, Culture=neutral, 
PublicKeyToken=null
>From domain :Name: OtherDomain
There are no context policies.

GetEntryAssembly = AssemblyInOtherDomain, Version=0.0.0.0, Culture=neutral, 
PublicKeyToken=null
>From domain :Name: OtherDomain
There are no context policies.

GetEntryAssembly = AssemblyInOtherDomain, Version=0.0.0.0, Culture=neutral, 
PublicKeyToken=null
>From domain :Name: test2.exe
There are no context policies.

GetEntryAssembly = test2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
>From domain :Name: test2.exe
There are no context policies.

GetEntryAssembly = test2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
>From domain :Name: test2.exe
There are no context policies.

GetEntryAssembly = test2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
>From domain :Name: test2.exe
There are no context policies.

Assembly: AssemblyInOtherDomain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
System.Reflection.Assembly
GetEntryAssembly = test2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
*/

using System;
using System.Reflection;

class TestiMain2 {

        static int Main( string [] args )
        {
                Console.WriteLine( "From domain :" + 
System.AppDomain.CurrentDomain.ToString() );
                System.Reflection.Assembly assembly = 
System.Reflection.Assembly.GetEntryAssembly();
                Console.WriteLine( "GetEntryAssembly = " + assembly.ToString() );
                return 0;
        }
}

Reply via email to