Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use custom serialization during .NET remoting?

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?

like image 619
Michael Hedgpeth Avatar asked Apr 17 '09 19:04

Michael Hedgpeth


2 Answers

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.

like image 78
Marc Gravell Avatar answered Nov 04 '22 15:11

Marc Gravell


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.

like image 1
Not Sure Avatar answered Nov 04 '22 16:11

Not Sure