Sure,
Mark the remote object (and any other objects it references) as serializable using 
either the [serializable] attribute or by implementing ISerializable.  Once the class 
has that, you can serialize it using the following code:

System.Runtime.Serialization.Formatters.Soap.SoapFormatter sf =
        new System.Runtime.Serialization.Formatters.Soap.SoapFormatter();

    System.IO.Stream stream = System.IO.File.Open
       ("objectGraph.soap", System.IO.FileMode.Create);

   sf.Serialize(stream,obj);

That should persist the object to the file system.  Reconstituting it is just as easy, 
just use the Deserialize method of the SoapFormatter object...

Hope that helps...

Don

-----Original Message-----
From: El Khiyari, Hachim [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 22, 2002 12:41 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Persistent Remote Objects


I would like to create a Remoting object that would persist its data to a file so that 
the object state is not lost after I restart the service.  Does the framework provide 
any way to do this automatically, or do I have to write code to load and save the 
state?

I appreciate any suggestion.

Thanks

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe 
to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to