Groups | Blog | Home
all groups > dotnet remoting > august 2006 >

dotnet remoting : Object references in a Mashal-by-Value object


Matthias Heise
8/3/2006 3:33:02 AM

Hello,

I discovered some problems if I want to serialize and transfer an object
hierarchy existing of next and child pointers.

Doing this I had to implement the ISerializable interface. Lets say I have
the following class:

public class Test : ISerializable
{
[NonSerialized]
public Test child;
public Test next;

public Test()
{
}

#region ISerializable Members

protected Test(SerializationInfo info, StreamingContext context)
{
this.next = (Test)info.GetValue("next", typeof(Test));
this.child = (Test)info.GetValue("child", typeof(Test));
}

public void
GetObjectData(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
{
info.AddValue("next", this.next);
info.AddValue("child", this.child);
}

#endregion
}

If I have a list of 5000 objects where each points to its next one I get a
time for deserialization by 2,3sec while an array of the same 5000 objects
with next==null takes only 0.1sec to be transferred to the client.

Is there any special technique to handle such references??

Thanks you.

Matthias

Matthias Heise
8/3/2006 4:06:02 AM

It makes sense, because I'm not discussing the difference between
Marshal-By-Ref and Marshal-ByValue.

I have already a .NET remoting connection between client and server via a
marshal-by-ref remote-object. This object has a method that is executed on
the server. This method has an out parameter which is of the type I talked
about. This argument/parameter is serialized automatically by .NET Remoting
when the method returned back to the client.

Inside this type I have members that are reference-type. That is described
in my short example.

Matthias



[quoted text, click to view]
Matthias Heise
8/3/2006 5:29:02 AM

Hello.

At first I just send the object with its reference to the next object etc.
This took 2.1sec for deserialization. After that I tested the following:

The first object takes all its neighbours and deletes the next and previous
references. All objects are put into an array which is than serialized. On
deserialization the next and previous structure is rebuild out of the array.

In this small sample deserialization took 0.2sec now. But in my bigger
project this solution was no help.

That's why I'm asking how these references should be handled on
serialization or deserialization using .NET Remoting.

Thanks

Matthias


[quoted text, click to view]
Tommaso Caldarola
8/3/2006 12:49:27 PM
[quoted text, click to view]

But the post make non sense with the subject.
Tommaso Caldarola
8/3/2006 2:18:10 PM
[quoted text, click to view]

pardòn, I mean Object reference not set...
AddThis Social Bookmark Button