Remoting and serialization

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Uttam (uttam_80_at_yahoo-dot-com.no-spam.invalid)
Date: 08/20/04


Date: 20 Aug 2004 10:02:58 -0500

Hello,
We are at a very crucial decision making stage to select between .Net
and Java. Our requirement is to download a class at runtime on the
client computer and execute it using remoting or rmi.
Just to keep my question short I am posting trimmed version of my
code.

//file: Serializable.cs

[Serializable]
public class Serializable:ISerializable
{
    public string Execute()
    {
        string str="original text";
        return str;
    }//public string Execute()
}//public class Serializable:ISerializable

//file: Client.cs

public class Client
{
    public static void Main()
    {
        try
        {
            ISerializable iSerializable =
(ISerializable)iRemoteObj.GetSerializableObj();
            response = iSerializable.Execute();
                            
        } catch (Exception e)
        {
        }
    }//public static void Main()
}

I want to keep ONLY interfaces on the client and Implementation on the
server. During runtime I want to get the remote object and execute
them locally.

I am able to do the same with the JAVA but in .NET I am forced to
have implementation files of these interfaces on the client computer.
which does not make any sense to me. that means I will have to update
the implementation on all the client computers in case I will have to
update some code in that class.
Then I don't even need remoting I can very well write a standalond
component;

This is what I get if i do not copy implementation class on the
client
-------------------------------------------------------------------------------------
System.Runtime.Serialization.SerializationException: Cannot find the
assembly Serializable, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null.

Server stack trace:
   at
System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
   at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo
assemblyInfo, String name)
   at
System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String
objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA,
Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader
objectReader, Int32 objectId, BinaryAssemblyInfo
 assemblyInfo, SizedArray assemIdToAssemblyTable)
   at
System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String
name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[]
typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader,
Int32 objectId, BinaryAssemblyInfo asse
mblyInfo, SizedArray assemIdToAssemblyTable)
   at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped
record)
   at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum
binaryHeaderEnum)
   at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage)
   at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
   at
System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryResponseMessage(Stream
inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
   at
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage
msg)

Exception rethrown at [0]:
   at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
   at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
   at NsServer.IRemoteObject.GetSerializableObj()
   at Client.Client.Main()