all groups > dotnet remoting > july 2003 >
You're in the

dotnet remoting

group:

Remoting ArrayList creates a copy?


Remoting ArrayList creates a copy? Aaron Roberts
7/1/2003 11:39:20 AM
dotnet remoting:
I have a remoted object which contains an ArrayList. I also have a
local ArrayList. When I set the remoted list = to my local one, its
fine. When I start adding or removing objects from the local list, the
list in the remoted object never changes.

What gives?

I also noticed that if I were to do a remObject.list.Remove(someObject)
method call, it won't actually remove the object, even though someObject
holds the same object reference as when a remObject.list.Add(someObject)
was done.

Any thoughts are appreciated!

Regards,
Aaron R>

--
Thank you,
Aaron Roberts
Southwest Research Institute
Advanced Interactive Technologies Department
(210)-522-5137
www.swri.org

Re: Remoting ArrayList creates a copy? Bruce Brown
7/7/2003 11:58:54 AM
Hi,

ArrayList is a serializable object, so "remObject.list" executes a remote
call that pulls over a copy of the list. Calling Remove then executes on
this local copy of the list. This means everytime you execute one of these
lines of code it is serializing the entire list each time.

You should expose some methods on your remotable object to play with the
list. Exposing the list directly may lead to unforseen usage and by
exposing a dedicated API you should be able to control access to with set
restrictions.

Hope this helps,

Regards,

- Bruce.


[quoted text, click to view]

AddThis Social Bookmark Button