[Mono-bugs] [Bug 63758][Cri] Changed - Assembly.Load fails when loading MS.NET compiled assembly

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 25 Aug 2004 10:59:21 -0400 (EDT)


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 lluis@ximian.com.

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

--- shadow/63758	2004-08-25 09:18:16.000000000 -0400
+++ shadow/63758.tmp.30695	2004-08-25 10:59:21.000000000 -0400
@@ -11,13 +11,13 @@
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: vivek.varma@honeywell.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: Assembly.Load fails in remoting scenario
+Summary: Assembly.Load fails when loading MS.NET compiled assembly
 
 Description of Problem:
 Lets assume there are two assemblies(dlls)
 ClassLib1.dll & ClassLib2.dll
 ClassLib2.dll has a reference to ClassLib1.dll
 
@@ -295,6 +295,60 @@
 	}
 
 }
 
 ################# CODE ENDS HERE############################
 
+
+------- Additional Comments From lluis@ximian.com  2004-08-25 10:59 -------
+Everything works ok if the ClassLibrary2 assembly received by the
+server  has been compiled with Mono. I get a null reference exception
+when Mono tries to load an assembly compiled with MS.NET. In fact I
+only get the exception the second time it tries to load the assembly,
+the first try works.
+
+This is a simpler test case:
+
+test.cs
+****************
+using System;
+using System.Runtime.Remoting;
+
+namespace RemoteClient
+{
+	class Class1
+	{
+		static void Main(string[] args)
+		{
+			string assemblypathname = @"ClassLibrary1.dll";
+			System.IO.FileStream fs = System.IO.File.OpenRead(assemblypathname);
+			System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
+			byte[] assembly = br.ReadBytes((int)br.BaseStream.Length);
+			br.Close();
+			fs.Close();
+			
+			System.Reflection.Assembly assm =
+System.Reflection.Assembly.Load(assembly);
+			Console.WriteLine("Loaded1 : " + assm.FullName);
+			
+			System.Reflection.Assembly assm2 =
+System.Reflection.Assembly.Load(assembly);
+			Console.WriteLine("Loaded2 : " + assm.FullName);
+		}
+	}
+
+}
+
+ClassLibrary1.cs -> ClassLibrary1.dll
+**************************************
+using System;
+
+namespace ClassLibrary1
+{
+	public class Class1
+	{
+		public void foo()
+		{
+			Console.WriteLine("ClassLibrar1::foo");
+		}
+	}
+}