[Mono-bugs] [Bug 63758][Cri] Changed - Assembly.Load fails in remoting scenario
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 25 Aug 2004 09:18:16 -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 vivek.varma@honeywell.com.
http://bugzilla.ximian.com/show_bug.cgi?id=63758
--- shadow/63758 2004-08-24 14:49:33.000000000 -0400
+++ shadow/63758.tmp.27741 2004-08-25 09:18:16.000000000 -0400
@@ -119,6 +119,182 @@
------- Additional Comments From lluis@ximian.com 2004-08-24 14:49 -------
I guess that the server has the same copy of ClassLib1.dll that the
client has, right?
What happens if you run both client and server in mono?
+
+------- Additional Comments From vivek.varma@honeywell.com 2004-08-25 09:18 -------
+I guess that the server has the same copy of ClassLib1.dll that the
+client has, right?
+Vivek>>Not sure what you meant, but i do not have ClassLib1.dll
+where the RemoteServer.exe runs
+
+
+What happens if you run both client and server in mono?
+Vivek>>Works fine. No exceptions or crashes.
+
+Vivek>>Have provided the sample code below.
+
+################# CODE STARTS HERE############################
+
+ClassLibrary1.cs (builds into ClassLibrary1.dll)
+************************************************
+using System;
+
+namespace ClassLibrary1
+{
+ public class Class1
+ {
+ public void foo()
+ {
+ Console.WriteLine("ClassLibrar1::foo");
+ }
+ }
+}
+
+
+ClassLibrary2.cs (builds into ClassLibrary1.dll) references
+ClassLibrary1.dll
+*********************************************************************
+**********
+using System;
+
+namespace ClassLibrary2
+{
+ public class Class1
+ {
+ public void foobar()
+ {
+ Console.WriteLine("ClassLibrary2::foobar");
+ ClassLibrary1.Class1 C1 = new
+ClassLibrary1.Class1();
+ }
+ }
+}
+
+
+IRemotingServer.cs (builds into IRemotingServer.dll)
+****************************************************
+using System;
+
+namespace RemoteServer
+{
+ public interface IRemotingServer
+ {
+ void RemoteLoad(byte[] assembly);
+ }
+}
+
+
+RemoteObject.cs (builds into RemoteObject.dll) references
+IRemotingServer.dll)
+*********************************************************************
+**********
+using System;
+
+namespace RemoteServer
+{
+ public class RemoteObject:
+MarshalByRefObject,IRemotingServer
+ {
+ public void RemoteLoad(byte[] assembly)
+ {
+ System.Reflection.Assembly assm =
+System.Reflection.Assembly.Load(assembly);
+ Console.WriteLine("Loaded : " +
+assm.FullName);
+ }
+
+ }
+}
+
+
+
+RemoteServer.cs (builds into RemoteServer.exe) references
+RemoteObject.dll
+*********************************************************************
+******
+using System;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+
+namespace RemoteServer
+{
+ class Class1
+ {
+
+ static void Main(string[] args)
+ {
+
+ Console.WriteLine ("Remote Server");
+
+ TcpChannel chan = new TcpChannel(8086);
+ ChannelServices.RegisterChannel(chan);
+
+ RemotingConfiguration.RegisterWellKnownServiceType
+(Type.GetType
+("RemoteServer.RemoteObject,RemoteObject"),"MyRemoteObject",
+WellKnownObjectMode.Singleton);
+
+ Console.WriteLine ("Press <Ctrl+C> to
+finish");
+ Console.ReadLine();
+ }
+ }
+}
+
+
+
+RemotingClient.cs (builds into RemoteClient.exe) refereces
+IRemotingServer.dll and RemoteObject.dll
+*********************************************************************
+*******************************
+ClassLibrary1.dll & ClassLibrary2.dll exist in the same folder where
+RemoteClinet.exe exists
+*********************************************************************
+************************
+
+using System;
+using System.Runtime.Remoting;
+
+namespace RemoteClient
+{
+ class Class1
+ {
+ static void Main(string[] args)
+ {
+
+
+ string assemblypathname =
+@"ClassLibrary2.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();
+
+ MarshalByRefObject obj;
+ if(args.Length == 0)
+ obj = (MarshalByRefObject)
+RemotingServices.Connect(typeof
+(RemoteServer.IRemotingServer), "tcp://localhost:8086/MyRemoteObject"
+);
+ else
+ obj = (MarshalByRefObject)
+RemotingServices.Connect(typeof
+(RemoteServer.IRemotingServer), "tcp://" + args[0]
++ ":8086/MyRemoteObject");
+ ((RemoteServer.IRemotingServer)
+obj).RemoteLoad(assembly);
+
+ }
+ }
+
+}
+
+################# CODE ENDS HERE############################
+