.NET Framework Bookmark and Share   
 index > .NET Remoting and Runtime Serialization > error in Deserialization
 

error in Deserialization

i have a class thatz derived from MarshalByRefObject;

i' have a client that has to serialize and deserialize this class.Deserialization throws exception.

public class TestClass:MarshalByRefObject

{

public TestClass(){ }

}

in TestClient ihave this code

//TestClient.cs

BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();

provider.TypeFilterLevel = TypeFilterLevel.Full;

IDictionary props = new Hashtable();

props["port"] = 8085;

TcpChannel channel = new TcpChannel(props, null, provider);

ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(TestClass), "TestClass",

WellKnownObjectMode.Singleton);

m_objTest = new TestClass();

MemoryStream stm = new MemoryStream();

RemotingSurrogateSelector ss = new RemotingSurrogateSelector();

BinaryFormatter formatter = new BinaryFormatter();

formatter.SurrogateSelector = ss;

formatter.Context = new StreamingContext(StreamingContextStates.All);

formatter.Serialize(stm, m_objTest);

stm.Position = 0;

TestClass j = (TestClass) formatter.Deserialize(stm);

i'm unable to find out hte mistake.Plz help!!

regards,

mamatha

mamathathunga

I am not sure I understand why you are using the RemotingSurrogateSelector. It would be helpful if you can share the exception you are getting. A shot in the dark: Please try nulling out SurrogateSelector before deserializing; i.e. Add

formatter.SurrogateSelector = null;

before formatter.Deserialize...

I hope this works

Sowmy Srinivasan
May I ask why you want to manually serialize and deserialize the object?
Jaimi

I am not sure I understand why you are using the RemotingSurrogateSelector. It would be helpful if you can share the exception you are getting. A shot in the dark: Please try nulling out SurrogateSelector before deserializing; i.e. Add

formatter.SurrogateSelector = null;

before formatter.Deserialize...

I hope this works

Sowmy Srinivasan

You can use google to search for other answers

Custom Search

More Threads

• Messaging between two apps on same pc
• Where to specify "ExclusiveAddressUse=false" in Xml file's System.runtime.remoting node
• Server Object not passing properties
• Default serialization questions
• Object has been disconnected or does not exist at the server.
• How does the remote object connect to the correct host
• tempory disable objects from remote sharing
• Remoting Changes Between Beta 2 and RTM
• How do I ensure async calls to a remote server are delivered in sequence?
• Permissions needed for XmlSerializer