473,416 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Remoting and serialization

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.SerializationExceptio n: Cannot find the
assembly Serializable, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null.

Server stack trace:
at
System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAssembly()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.GetType(BinaryAssemblyInfo
assemblyInfo, String name)
at
System.Runtime.Serialization.Formatters.Binary.Obj ectMap..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.Obj ectMap.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.__B inaryParser.ReadObjectWithMapTyped(BinaryObjectWit hMapTyped
record)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWithMapTyped(BinaryHeaderEnu m
binaryHeaderEnum)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Remoting.Channels.CoreChannel.Deser ializeBinaryResponseMessage(Stream
inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
at
System.Runtime.Remoting.Channels.BinaryClientForma tterSink.SyncProcessMessage(IMessage
msg)

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

Nov 16 '05 #1
6 2696
Uttam,

It sounds like you want a class factory that works over a network, where
a class generator on another machine is going to give you the implementation
of an interface when you call it.

Something like this is hard to do with .NET remoting, because quite
honestly, this isn't a remoting issue. Rather you are downloading an
implementation and then executing it locally.

You could do this with .NET, but not with remoting. Rather, I would
download the assembly with the implementation (including the type), and load
it into another application domain, and then access the type through the
interface.

This can easily be done with calls to the static Load method on the
Assembly class, as well as the static CreateDomain method on the AppDomain
class. Once you load the Assembly into the app domain (through a call to
the DoCallback method on the AppDomain you create), you can create an
instance of the type, and then cast it to the interface.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Uttam" <ut******@yahoo-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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.SerializationExceptio n: Cannot find the
assembly Serializable, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null.

Server stack trace:
at
System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAssembly()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.GetType(BinaryAssemblyInfo
assemblyInfo, String name)
at
System.Runtime.Serialization.Formatters.Binary.Obj ectMap..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.Obj ectMap.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.__B inaryParser.ReadObjectWithMapTyped(BinaryObjectWit hMapTyped
record)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWithMapTyped(BinaryHeaderEnu m
binaryHeaderEnum)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Remoting.Channels.CoreChannel.Deser ializeBinaryResponseMessage(Stream
inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
at
System.Runtime.Remoting.Channels.BinaryClientForma tterSink.SyncProcessMessage(IMessage
msg)

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

Nov 16 '05 #2
You can still use interfaces. That is not a problem.

Googling ".net remoting interfaces" give you tons of hits. Here is an easy,
cheesy example

http://www.c-sharpcorner.com/Tutoria...otingDT003.asp
"Uttam" <ut******@yahoo-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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.SerializationExceptio n: Cannot find the
assembly Serializable, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null.

Server stack trace:
at
System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAssembl
y() at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.GetType(BinaryAs
semblyInfo assemblyInfo, String name)
at
System.Runtime.Serialization.Formatters.Binary.Obj ectMap..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.Obj ectMap.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.__B inaryParser.ReadObjectWith
MapTyped(BinaryObjectWithMapTyped record)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith
MapTyped(BinaryHeaderEnum binaryHeaderEnum)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(Head
erHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S
tream serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Remoting.Channels.CoreChannel.Deser ializeBinaryResponseMessag
e(Stream inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
at
System.Runtime.Remoting.Channels.BinaryClientForma tterSink.SyncProcessMessag
e(IMessage msg)

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

Nov 16 '05 #3
Hi Uttam,

What you have on the Java side is RMI, which is EXACTLY the same as a
MarshalByRefObject in .NET. Hmm, only easier because you don't have to do
any post-processing steps to make it work (except to create a remoting server
that escrows the marshalled objects).

In fact, if you use MarshalByRefObject for all of your "shared" objects (not
classes, mind you, because you STILL have to leave a copy of the interface
definition on the client), then you can make use of an interface for all of
your interactions. The Microsoft PetShop is an excellent example of making
use of interfaces and serialization. To extend it to reference marshalling,
just envision "MarshalByRefObject" as the base class for all of their DAL
classes.

The decision to use Java versus .NET isn't so much about technology as it is
about your target platform, in this case. Both technologies will work the
same, and you will find that .NET is *much* easier to program than RMI and
Java (I have 8 years of Java under me and almost 3 years of .NET). The
*best* part of .NET is the container - you get it with ever installation of
Windows "Professional" and server, whereas Java will require you to go and
find a container.

If you need further help or advice, please don't hesitate to contact me
direct via email (jw*@javatopia.com). I am more than happy to help out a
fellow Java/.NET programmer.

One more thing - in the Java world, remember that any time you de-serialize
an object, you need the ENTIRE class graph for that object on your client.
Serialization is a nasty beast no matter how you shake it. .NET remoting
using object references, on the other hand, allows you to proxy interfaces on
the client, which means you get to leverage a shallow representation of the
server object and not sacrifice functionality.

-- Jake
jw*@javatopia.com
"Uttam" wrote:
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.SerializationExceptio n: Cannot find the
assembly Serializable, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null.

Server stack trace:
at
System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAssembly()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.GetType(BinaryAssemblyInfo
assemblyInfo, String name)
at
System.Runtime.Serialization.Formatters.Binary.Obj ectMap..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.Obj ectMap.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.__B inaryParser.ReadObjectWithMapTyped(BinaryObjectWit hMapTyped
record)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWithMapTyped(BinaryHeaderEnu m
binaryHeaderEnum)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Remoting.Channels.CoreChannel.Deser ializeBinaryResponseMessage(Stream
inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
at
System.Runtime.Remoting.Channels.BinaryClientForma tterSink.SyncProcessMessage(IMessage
msg)

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

Nov 16 '05 #4
Thanks to all,
I will try to follow each one of the advice one by one and it will
take some time.
Just for info I tried 'Kevin C' example from
http://www.c-sharpcorner.com/Tutoria...otingDT003.asp
But it is again marshall by reference though it implements
[serializable].
I tested by writing 'System.Console.WriteLine("Executing at client");'
in that class Resume. If it is marshall by value then this class is
supposed to be executed in the client's domain and print this message
at the client console but it is printing the message at the server.

Once again thanks all.

Nov 16 '05 #5
I'm getting the same problem when trying to use the David Talbot
example. The object is passed ByRef - you can check this using
Environment.MachineName;
I'm going to post the question on the remoting newsgroup
Nov 16 '05 #6
no********@bristol94.freeserve.co.uk (Noel Watson) wrote in message news:<84**************************@posting.google. com>...
I'm getting the same problem when trying to use the David Talbot
example. The object is passed ByRef - you can check this using
Environment.MachineName;
I'm going to post the question on the remoting newsgroup


Here is the thread on the remoting group.

http://groups.google.com/groups?dq=&...ework.remoting
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Skip | last post by:
Hi, I get the following exception thrown when I try to run my code: "An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll Additional...
15
by: Sharon | last post by:
I’m trying to build a generic Publisher-Subscriber that will work over the net, so I’m using the Remoting. I wish that the subscriber user will be notify about the messages sent by the...
11
by: ajou_king | last post by:
I was running some tests on my Win32 1GHZ processor to see how long it would take to transmit objects numerous times via TCP/IP using C# ..NET Remoting vs the C++ trustworthy method of binary...
9
by: Howard Swope | last post by:
I came across an interesting bug I thought I would throw out there. It occurs when you are remoting a parameter that is of the same type of the class that is being called for example the first line...
3
by: Steve | last post by:
I've been following a couple remoting tutorials on the web, they are all pretty much the same. I've got my different applications built(client, server and remote object (dll)) The client is...
2
by: Satish A | last post by:
Hi, I'm writing a n-tier ASP.NET application with BusinessLogic as Remoting Objects While passing custom business entity object byref to remoting object methods i'm getting following error ...
4
by: WinDev | last post by:
What does this exception message mean? Type System.DelegateSerializationHolder and the types derived from it (such as System.DelegateSerializationHolder) are not permitted to be deserialized at...
2
by: Jigar.Patel | last post by:
Hi, I have following enum definition. public enum OperationTypes { All = 1, New = 2, View = 4,
0
by: ShaneN | last post by:
I'm working on a remoting application where the client only references interfaces for all wellknown objects. I currently have an object, Request being exposed: Imports System.Runtime.Remoting...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.