Yes; to send data out-of-process (especially over a network) you need to serialize it. Mostly this is implicit in .NET - you just tell it how. With "asmx" it'll use XmlSerializer
, so not much needed (except a public .ctor()
). With WCF, it is best to use explicit [DataContract]
etc. Note that in both cases it uses xml-based variants; the description of "binary" is simple: everything is binary (or worse: electrons, or fields, or something) in computers. The text representation is just in our imagination ;-p
If you use "remoting", then it uses BinaryFormatter
by default, which is (as it suggests) a true binary formatter, but it has a few niggles of its own.
I would draw a big distinction between using data for transport (comms etc), and for storage. In the first case, it is short-lived, and you can abuse a few more SOA techiques if you absolutely must (although I try not to) - for example, BinaryFormatter
and NetDataContractSerializer
include type metadata, which is loosely acceptable, but can be a pain if you store it anything other than short-term. Once stored, you need to be very careful that you can recreate it, and metadata/field-based storage is very brittle.
For storage, I stick with contract-based data:
- xml (via
XmlSerializer
, or DataContractSerializer
)
- json
- binary (perhaps protobuf-net)
(and in the bottom case, binary means: not text-based at all)