Re: Serializing XmlDocument to SerializationInfo



Hi Sam,

Are you worried about the size of data being transmitted to/from a remoting client?

Prior to version 2 you can use an IPCChannel which alleviates the requirement for sockets since it uses local pipes only.

If you are using binary serialization over Tcp that will help to decrease the size of messages transmitted to/from a remoting
client. Your compression idea sounds like it will help as well. As you mentioned you can serialize the XmlDocument into a
MemoryStream and compress the stream. Just add the stream reference to the SerializationInfo with a custom key like, "doc_bits".
Stream is serializable (as is MemoryStream, of course). In your deserialization constructor just pull the stream from the
SerializationInfo, decompress and deserialize back into an XmlDocument.

--
Dave Sexton

<scarleton@xxxxxxxxx> wrote in message news:1154616494.661758.158430@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dave Sexton wrote:

Hi Sam,

That depends on the reason why you are serializing the TextDocument and its
containing object in the first place. Your could save the TextDocument to a file,
possibly on a web server, and serialize a path string. During deserialization
locate the file (and download it if necessary), then reload it into a TextDocument.
You might have to download the document asynchronously, so the client should
be aware of any possible caveats.

Dave,

Thank you for your reply!

I have two types of serialization going on. One is to a file and the
other is across the wire. The application I am working on is a
client/server app where currently both are on the same physical
machine, in version 2, they can be on separate machines, but all in the
same local area network. There is no plain to ever make this system
work over the Internet or use any web server type of things.

The XML is created in an XmlDocument object that is the raw data for a
report. The XmlDocument object is being added to a C# business class
call "ReportDocument" which contains additional information. It is
within this Report class that I need to figure out how to serialize the
XmlDocument.

The code that writes a ReportDocument to file is generic, right now at
least, to how all documents within the system are written to file and
they all depend on the object implementing the ISerializable interface.
I am using standard remoting to send objects across the wire, right
now, too. So both remoting and writing to file is using ISerializable.

After some testing, it looks like if the text within the XML is
compressed, I can get the size down to under half a meg of data, so I
would be comfortable with serializing that size of binary blob. In the
short term, I think this is the best approach. Is there a better one?

Assuming my approach, I figure I can stream the XmlDocument to a memory
stream and then compress the memory stream, but I am back at how best
to stream this compresed blob into the SerializationInfo. Any
thoughts?

Sam



.



Relevant Pages

  • Re: Fast streaming via Remoting
    ... MethodCall Message to be send to the server. ... Stream, this would not result in a NetworkStream into ... the Server can write and the Client can read. ... You should not use Remoting in this case. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: remoting simple..
    ... Sending a dataset over remoting will serialize it as XML, ... tou shoudl be able to retrieve it as a DataSet on the client side. ... > I am writing a simple remoting app.. ... > now in my service class if I reference the dataset then I also need to ...
    (microsoft.public.dotnet.general)
  • how to stream data from client to server.
    ... can someone show me how to stream large amount of data from client back to ... i have serialize an image from the client, but the server only sees half of ... the serialize xml. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Send a word document
    ... how can I send a word document over remoting from a client to a server? ... how to put this stream together on the client ...
    (microsoft.public.dotnet.framework.remoting)
  • PrintDocument and serialization
    ... I want to serialize a PrintDocument because I want to send it to a Client ... with Remoting. ...
    (microsoft.public.dotnet.framework)