[Mono-bugs] [Bug 69181][Nor] Changed - Bug in AppDomain.GetAssemblies

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 9 Nov 2004 13:50:32 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by mono@evain.net.

http://bugzilla.ximian.com/show_bug.cgi?id=69181

--- shadow/69181	2004-11-09 13:36:49.000000000 -0500
+++ shadow/69181.tmp.31321	2004-11-09 13:50:32.000000000 -0500
@@ -63,6 +63,79 @@
 }
 
 ------- Additional Comments From bmaurer@users.sf.net  2004-11-09 13:36 -------
 This is nasty. Basically the assembly builder is not serializeable, 
 and we need to transfer it across ad's. I have to see what msft does 
 here.
+
+------- Additional Comments From mono@evain.net  2004-11-09 13:50 -------
+Msft Framework behaviour :
+If you have not defined any Dynamic assembly, like in this test case :
+
+using System;
+using System.Reflection;
+
+public class Consumer {
+    public static void Main() {
+        try {
+            AppDomain ad = AppDomain.CreateDomain("LoadingDomain",
+                AppDomain.CurrentDomain.Evidence,
+AppDomain.CurrentDomain.SetupInformation);
+            ad.Load("test");
+            Assembly[] asms = ad.GetAssemblies();
+            foreach (Assembly asm in asms) {
+                Console.WriteLine(asm.GetName().FullName);
+            }
+            AppDomain.Unload(ad);
+        } catch (Exception e) {
+            Console.WriteLine(e.Message);
+            Console.WriteLine(e.StackTrace);
+        }
+    }
+}
+
+The output will be :
+
+mscorlib, Version=1.0.5000.0, Culture=neutral,
+PublicKeyToken=b77a5c561934e089
+test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+
+But if you have defined an dynamic assembly, like in this test case
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+public class Consumer {
+    public static void Main() {
+        try {
+            AppDomain ad = AppDomain.CreateDomain("LoadingDomain",
+                AppDomain.CurrentDomain.Evidence,
+                AppDomain.CurrentDomain.SetupInformation);
+            ad.Load("test");
+            
+            
+            AssemblyName assemblyName = new AssemblyName();
+            assemblyName.Name = "dna";
+
+            AssemblyBuilder assemblyBuilder =
+ad.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
+            
+            Assembly[] asms = ad.GetAssemblies();
+
+            foreach (Assembly asm in asms) {
+                Console.WriteLine(asm.GetName().FullName);
+            }
+            AppDomain.Unload(ad);
+        } catch (Exception e) {
+            Console.WriteLine(e.Message);
+            Console.WriteLine(e.StackTrace);
+        }
+    }
+}
+
+You'll get the same exception as you thrown, ie, a
+System.Runtime.Serialization.SerializationException.
+
+Tests are done with the version 1.1 of the framework.
+
+Jean-Baptiste