Serializable object containg MarshalByRefObject Object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nick_tucker@hotmail.com

    Serializable object containg MarshalByRefObject Object

    If I have an Arraylist(which is marked as serailizable) which contains
    objects derived from MarshalByRefObj ect something like below

    public class MyArray
    {
    private ArrayList m_al;

    public void MyArray()
    {
    m_al.Add(MyObje ct("XXX"));
    m_al.Add(MyObje ct("YYY"));
    m_al.Add(MyObje ct("ZZZ"));
    }
    public ArrayList AL{get{return m_al;}}
    }

    public class MyObject:Marsha lByRefObject
    {
    private string m_Data;
    public MyObject(string sData)
    {
    m_Data = sData;
    }
    public string Data{get{return m_Data;}}
    }

    When I do the following on the client:

    ArrayList alRemotedArrayL ist = <Get ArrayList from server Via Remoting>
    foreach(MyObjec t obj in alRemotedArrayL ist)
    {
    Console.WriteLi ne(obj.Data);
    }

    Am I correct in thinking that for each call of 'obj.Data' I am making a
    call to the server. And that alRemotedObject s is a collection of
    Proxies pointing to the object on the server???

    Thanks,
    Nick

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Serializable object containg MarshalByRefObj ect Object

    Nick,

    Yep, that's pretty much how it works. That's the whole point of
    MarshalByRefObj ect, when you access it across app-domain boundaries, a proxy
    is created on the client side to make calls to the server.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    <nick_tucker@ho tmail.com> wrote in message
    news:1128432514 .027129.159480@ g14g2000cwa.goo glegroups.com.. .[color=blue]
    > If I have an Arraylist(which is marked as serailizable) which contains
    > objects derived from MarshalByRefObj ect something like below
    >
    > public class MyArray
    > {
    > private ArrayList m_al;
    >
    > public void MyArray()
    > {
    > m_al.Add(MyObje ct("XXX"));
    > m_al.Add(MyObje ct("YYY"));
    > m_al.Add(MyObje ct("ZZZ"));
    > }
    > public ArrayList AL{get{return m_al;}}
    > }
    >
    > public class MyObject:Marsha lByRefObject
    > {
    > private string m_Data;
    > public MyObject(string sData)
    > {
    > m_Data = sData;
    > }
    > public string Data{get{return m_Data;}}
    > }
    >
    > When I do the following on the client:
    >
    > ArrayList alRemotedArrayL ist = <Get ArrayList from server Via Remoting>
    > foreach(MyObjec t obj in alRemotedArrayL ist)
    > {
    > Console.WriteLi ne(obj.Data);
    > }
    >
    > Am I correct in thinking that for each call of 'obj.Data' I am making a
    > call to the server. And that alRemotedObject s is a collection of
    > Proxies pointing to the object on the server???
    >
    > Thanks,
    > Nick
    >[/color]


    Comment

    • Brendan Grant

      #3
      RE: Serializable object containg MarshalByRefObj ect Object

      Am I correct in thinking that instances of MyObject exist on the server and
      that MyArray is built on the client?

      If so... then yes, each call to obj.Data requires a round trip to the server
      and that alRemotedObject s is nothing but proxies, provided that you have
      setup remoting for either instances of MyObject (ie
      RegisterWellKno wnClientType on the client) or for the contents of MyArray to
      exist on the server.

      Brendan

      "nick_tucker@ho tmail.com" wrote:
      [color=blue]
      > If I have an Arraylist(which is marked as serailizable) which contains
      > objects derived from MarshalByRefObj ect something like below
      >
      > public class MyArray
      > {
      > private ArrayList m_al;
      >
      > public void MyArray()
      > {
      > m_al.Add(MyObje ct("XXX"));
      > m_al.Add(MyObje ct("YYY"));
      > m_al.Add(MyObje ct("ZZZ"));
      > }
      > public ArrayList AL{get{return m_al;}}
      > }
      >
      > public class MyObject:Marsha lByRefObject
      > {
      > private string m_Data;
      > public MyObject(string sData)
      > {
      > m_Data = sData;
      > }
      > public string Data{get{return m_Data;}}
      > }
      >
      > When I do the following on the client:
      >
      > ArrayList alRemotedArrayL ist = <Get ArrayList from server Via Remoting>
      > foreach(MyObjec t obj in alRemotedArrayL ist)
      > {
      > Console.WriteLi ne(obj.Data);
      > }
      >
      > Am I correct in thinking that for each call of 'obj.Data' I am making a
      > call to the server. And that alRemotedObject s is a collection of
      > Proxies pointing to the object on the server???
      >
      > Thanks,
      > Nick
      >
      >[/color]

      Comment

      Working...