serialize generic dictionary with .NET 3.5?

  • Thread starter Thread starter not_a_commie
  • Start date Start date
N

not_a_commie

So I thought I saw recently some new MS serializer class (part of
workflow foundation or something) that would serialize a lot of types
the old XmlSerializer would not do. This included generic
dictionaries. Can somebody point me to documentation on this or was I
just up in the night?
 
not_a_commie,

You are looking for the NetDataContractSerializer class in the
System.Runtime.Serialization namespace (and the dll of the same name). This
was introduced in .NET 3.0, not 3.5.

There is also the DataContractSerializer. If you need to send CLR type
information across the wire, then you use the NetDataContractSerializer. If
just want the other side to understand the contract, then you use the
DataContractSerializer.

Either way, you can serialize to XML, but it has the potential to be
pretty complex, so be warned.

Also, the dictionary, as well as the types used as parameter types have
to be marked as serializable, or use the new DataContract attribute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top