473,322 Members | 1,379 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,322 software developers and data experts.

remoting general marshal

Tom
I think I'm still a little rough on the principle and understanding of
Marshal by value and Marshal by reference after reading various materials.

my understanding of Marshal by value is that the object is copied and passed
by value out of the application domain. So does that mean the ENTIRE server
object is copied to the client side ? thus all calculations are done on the
client side ?

ie. if client/server

if server has add(int x, int y)

and client calls on server add(5,6)

by Marshal by value does that mean the ENTIRE object of add is copied and
process of 5 + 6 is performed on the client ? is that what it means ?

but then again my understanding of an OBJECT is simply a reference to a
class or method. so copying an object is merely copying a method's reference
so what is the difference between Marshal by value and Marshal by reference
?
Thanks guys, I have read many books but still can't grasp it.

Tom
Nov 16 '05 #1
3 1892
Tom,

See inline:
my understanding of Marshal by value is that the object is copied and
passed
by value out of the application domain. So does that mean the ENTIRE
server
object is copied to the client side ? thus all calculations are done on
the
client side ?

ie. if client/server

if server has add(int x, int y)

and client calls on server add(5,6)

by Marshal by value does that mean the ENTIRE object of add is copied and
process of 5 + 6 is performed on the client ? is that what it means ?
The concept of whether or not something is passed by reference or by
value (as it relates to remoting) applies to a type when it is used as a
parameter to a call that occurs outside of the current app domain. In this
case, you determine whether or not 5 and 6 are passed by value or by
reference to the other app domain. Because they are of type Int32, and that
does not derive from MarshalByRefObject, it will be passed by value. This
means that the values of 5 and 6 will be copied over to the new application
domain, and any changes made to them are not going to be seen by you.

Now, if the signature looked like this:

DoSomething(System.Windows.Forms.Control control)

And you passed a textbox, then the TextBox would not be copied. Rather,
a reference to it would be passed to the new application domain. Any calls
made to the control parameter in the other application domain would be
remoted back to the connecting client.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com


but then again my understanding of an OBJECT is simply a reference to a
class or method. so copying an object is merely copying a method's
reference
so what is the difference between Marshal by value and Marshal by
reference
?
Thanks guys, I have read many books but still can't grasp it.

Tom

Nov 16 '05 #2
Hi Tom,
my understanding of Marshal by value is that the object is copied and
passed
by value out of the application domain.
Copy and paste implies that the clipboard is involved. The clipboard is not
involved the object is serialized (its data part of course) whether in a
binary stream or in some text format (SOAP) send thru some channel to the
client and deserialized on the cliend side in the client's environment. From
this point on the obejct lives and works on the client machine.
So does that mean the ENTIRE server
object is copied to the client side ? thus all calculations are done on
the
client side ?
Entire server or whatever object is used. It is possible that the server is
not one monolithic object. it might use couple of helper objects that can be
serialized by value and perform some operation on the client side. The core
of the server on the other side might be (and usually is) marchaled by ref
and lives on the server machine.
if server has add(int x, int y)

and client calls on server add(5,6)

by Marshal by value does that mean the ENTIRE object of add is copied and
process of 5 + 6 is performed on the client ? is that what it means ?
No, the process of marchaling (serialization/deserialization) of the object
that declares this method is done when you request that object rather than
when you call its methods. I'd say 'request the object' because if you
careate the object with *new* operator it is not different than creation of
any other local object. Marshaling occures when you get that object as
return value or form property of the marshaled by ref object on the server.
See marchaled by value means that the object has nothing special beside that
it is serializable.

but then again my understanding of an OBJECT is simply a reference to a
class or method. so copying an object is merely copying a method's
reference
so what is the difference between Marshal by value and Marshal by
reference
?


Marshal by ref means that one the server and cliend sides proxy objects are
created. Those proxies are in charge of treansfer the method calls between
them via some medium and hide the fact form the client that actually the
real logic and data are on other machine(or process or whatever). What the
client actually works with is a proxy object. That's why when you marchal by
ref only methods can be called (or properties, which are methods after all).
Marchal by value on the other hand means that state of the object (data ) is
packed and send to the client. Then the client creates a new object and
initilizes it with that data. So it gets copy of the object on its side.
This is totally new object and has nothing to do with its original on the
server.

This is most likely ref and value objects when remoting is not involved. You
know that when you copy reference to a ref object only the reference is copy
(the address so to speak). The object in the heap is only one. When you
copy value objects (like Int32 for example) you get new copy and from this
point on both objects has nothing to do with each other and they live
separate lives.
--
HTH
Stoitcho Goutsev (100) [C# MVP]

Nov 16 '05 #3
Tom
ahh thankyou now I understand
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OH**************@TK2MSFTNGP12.phx.gbl...
Tom,

See inline:
my understanding of Marshal by value is that the object is copied and
passed
by value out of the application domain. So does that mean the ENTIRE
server
object is copied to the client side ? thus all calculations are done on
the
client side ?

ie. if client/server

if server has add(int x, int y)

and client calls on server add(5,6)

by Marshal by value does that mean the ENTIRE object of add is copied and process of 5 + 6 is performed on the client ? is that what it means ?
The concept of whether or not something is passed by reference or by
value (as it relates to remoting) applies to a type when it is used as a
parameter to a call that occurs outside of the current app domain. In

this case, you determine whether or not 5 and 6 are passed by value or by
reference to the other app domain. Because they are of type Int32, and that does not derive from MarshalByRefObject, it will be passed by value. This
means that the values of 5 and 6 will be copied over to the new application domain, and any changes made to them are not going to be seen by you.

Now, if the signature looked like this:

DoSomething(System.Windows.Forms.Control control)

And you passed a textbox, then the TextBox would not be copied. Rather, a reference to it would be passed to the new application domain. Any calls made to the control parameter in the other application domain would be
remoted back to the connecting client.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com


but then again my understanding of an OBJECT is simply a reference to a
class or method. so copying an object is merely copying a method's
reference
so what is the difference between Marshal by value and Marshal by
reference
?
Thanks guys, I have read many books but still can't grasp it.

Tom


Nov 16 '05 #4

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

Similar topics

6
by: Catherine Jones | last post by:
Hi all, we need urgent help in a matter. We are trying to pass a COM object from the client to server and are facing some problems in the same. We've our client in C# as well as the Server...
5
by: Mark Broadbent | last post by:
Could someone clear this up for me a bit. I am a little bit uncertain about this but this is my understanding. Please correct where wrong or bits missing. There are two types of remoting :- ...
2
by: Mark Broadbent | last post by:
Could someone clear this up for me a bit. I am a little bit uncertain about this but this is my understanding. Please correct where wrong or bits missing. There are two types of remoting :- ...
5
by: Mark | last post by:
What I want to do is call a function in my main form/class from the server (which the another program/client calls). The main form does not really create a server object so I can't pass the...
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...
4
by: Sharon | last post by:
Hi, I'm using the remoting, and I have a remoting object that has a public event that other processes should register to it. But when the client process is registering to the remote event, it...
2
by: Sagaert Johan | last post by:
Hi When the remoting server starts and the client immediate begins calling the remote object on the server no problems. But when the client does not need to access the remote object for some...
4
by: Rich | last post by:
Can anyone suggest a good (current) tutorial on how to do basic remoting with C# (2005 express edition)?
1
by: Jeff | last post by:
..NET 2.0 Is generic lists faster then tradional lists when sending over a collection of objects (value by reference) in .NET remoting. Lets say if a list of object should be sent from a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.