Hi,
I have serialized remote object. I deserialize it OK:
bufferEvent = (
Event)binReader.Deserialize(inStream);After that I get remote object of the same type, and I want to copy the data from the buffer object to the remote object, in order again all clients to maniplate the "old" remote object, which was serialized on previous program close:
this
.thisEvent = (Event)Activator.GetObject(typeof(Event), "tcp://localhost:8086/Hi"); - this line is ok, I get remote object//now I call set method on the remote object - failure :(
List<Candidate> candidatesList = bufferEvent.getCandidates();
this
.thisEvent.setCandidates(candidatesList); - this line throws Exception"An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dl. Additional information: Object reference not set to an instance of an object."
It is very strange, because if I make the same call but with setter function which sets not list, but only one reference to object it passes OK, i.e.
this call executes OK:
this
.thisEvent.setEventTime(bufferEvent.getEventTime());Do you have an idea why calling set method with List parameter fails with such Exception?
Thanks, Peter
Peter MinevPosted Jan 26, 2009, 7:05 AM
I figured-out the problem.
I have one class derived from MarshalByRefObject. This class contains members, which again derive from MarshalByRefObject. If I call setter method which manipulates class-member derived by MarshalByRefObject, exception is thrown. If I call set method on member which doesn't derive (in my case standard types like DateTime), exception is not thrown.
The reason is that the server identity of MarshalByRefObject is lost during serialization/deserialization (in order to be able to do it indeed).
So the workaround is to constuct the objects again with the same data, instead to pass as function parameters the objects directly.