Hi everyone. I'm having troubbles in remoting an Int32 array.
All the data are correctly passed from the server to the client, but if in
the client I try to write an element of the array the data is not passed back
to the server.
Can anyone explain me why?
Thanks!
Erick Sgarbi - 05 Aug 2005 12:13 GMT
You can use remoting to mashalling data in 2 ways MarshallByRef and
MarshallByValue.
MarshallByValue is the process of serializing the entire graph of the
object and sending it to a remote host (client) where it will be
deserialized which at that point the object itself has a different
reference from the server and it is not the same object that was send
back to the remote host. If you make changes to the object on the client
nothing will happen with the server's object because they are different.
MarshallByRef is the ability to create an object on the server and
sending a proxy to the client which represents the remote object (a
stub) of the real object. When the client make calls to the proxy (like
calling a method or setting a property) messages are marshaled back to
the server and redirected to the real object.
In order to create a proxy (MarshallByRef) an object must inherit from
System.MarshallByRefObject (or System.ContextBoundObject) where if you
want to MarshallByValue the object must be serializable (Containt the
SerializableAttribute) or provide your own serialization.
The reason why your array does not change on the server is because
System.Array does not inherit from System.MarshallByRef moreover it is a
serializable type. The object you are changing is not the same object
sitting on the server consequently you are only changing a local copy.
Please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/h
awkremoting.asp
HTH
Erick Sgarbi
www.blog.csharpbox.com
> Hi everyone. I'm having troubbles in remoting an Int32 array.
> All the data are correctly passed from the server to the client, but if in
[quoted text clipped - 3 lines]
>
> Thanks!