views:

629

answers:

2

I've written a custom serialization routine that does not use ISerializable or the SerialzableAttribute to save my objects to a file.

I also remote these same objects and would like to use the same serialization technique. However, I don't want to implement ISerializable because my serialization method is completely decoupled from my objects (and I'd like for it to stay that way).

Is there an easy way (possibly with remoting sinks) where I can take a stream and write bytes to it and on the other side read bytes from it, skipping the Serialization framework in .NET?

+1  A: 

If you want to explicitly deal with streaming bytes between your processes, use pipes. Here's one getting-started on named pipes, Google has plenty as well.

Not Sure
Or you could use System.IO.Pipes if you're on .NET 3.5 or higher.
romkyns
+2  A: 

If you want to use remoting then you are limited to BinaryFormatter. Normally, you can use a "serialization surrogate" to provide a serializer separate to the formatter, but AFAIK this deoesn't work with .NET remoting.

However; if you write your own RPC stack (over TCP/IP or HTTP, for example), you'll have a lot more control. Equally, with WCF you can replace the serializer via a behavior. I use both of these tricks in protobuf-net (the WCF hooks are here).

Not sure you can do this with remoting though - you'd probably have to use ISerializable.

Marc Gravell