steven

steven

  • NA
  • 24
  • 41.8k

.Net Remoting, I have to use marshal by reference in this case?

Oct 6 2011 11:58 PM
//remotable object 
[Serializable]
  public class MBV
  {
  public int Data
  {
  get;
  set;
  }
  }
  public class MBR : MarshalByRefObject
  {
  public int Data
  {
  get;
  set;
  }
  }

//server side
//ellipsis

//client side
//create channel/object etc...

MyObject obj = (MyObject)Activator.GetObject(typeof(MyObject), "tcp://localhost:2222/myObj");

obj.Mbv = new MBV();
obj.Mbv.Data = 1112;  //It seems no effect of this statement for marshalByValueObject. 
Console.WriteLine(obj.Mbv.Data);

obj.Mbr = new MBR();
obj.Mbr.Data = 1112;
Console.WriteLine(obj.Mbr.Data);

//OUTPUT,
0
1112

 How can i change the data of marshalByValueObject?  I have to use marshal by reference in this case?


Answers (2)