Remoting Serialization Issue

I've got a wrapper class for MyClass, called RemotableMyClass (which inherits from MarshalByRefObject).  I've got an object that is not marked as serializable I'm using inside MyClass (which implements ISerializable to "take care" of that).

In the server, I have...



ChannelServices.RegisterChannel(new HttpChannel(1234));
RemotingConfiguration.ApplicationName = "MyTest";
ObjRef objRef = RemotingServices.Marshal(instantiationOfRemotableMyClass, "MyTest");


 

In the client, I have...



RemotingConfiguration.RegisterWellKnownClientType(typeof(RemotableMyClass), "http://localhost:1234/MyTest");
RemotableMyClass rmc = new RemotableMyClass();

MyClass mc = new MyClass();
mc.ObjectNotMarkedAsSerializable.someProperty = 2;
rmc.MyClass = mc;


 


Why do I receive a serialization error about the
ObjectThatIsNotMarkedAsSerializable  MyClass serializes and deserializes fine when using a BinaryFormatter.




[Serializable]
public class MyClass : ISerializable
{
  public ObjectNotMarkedAsSerializable obj = new ObjectNotMarkedAsSerializable;
  void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
  {
    // implementation to serialize ObjectNotMarkedAsSerializable
  }

  public MyClass (SerializationInfo info, StreamingContext context)
  {
    // implementation to deserialize ObjectNotMarkedAsSerializable
  }

}

 




[Serializable]
public class RemotableMyClass : MarshalByRefObject
{
  public MyClass myClass;
}


 


Answer this question

Remoting Serialization Issue

  • Dawa

    Are you using the BinaryFormatter or the SoapFormatter Also, you could try putting the NonSerialized attribute on the member "obj" in MyClass.
  • Mark Philip

    Can you please attach a small program to demonstrate the problem

  • Remoting Serialization Issue