14
голосов
2ответов
3884 просмотров

Test for Optional Field when using .NET Custom Serialization

Given a class like this one: [Serializable] public class MyClass { string name; string address; public MyClass(SerializationInfo info, StreamingContext context){ name = info.GetString("name"); if(/* todo: check if a value for address exists */) address = ...

4
голосов
4ответов
31673 просмотров

Convert a byte[] array into DataTable

I saved an object of type DataTable into SQL 2005 database in a field of type varbinary. I want to retrieve it back but I wasn't able to type cast it. This is how i saved it. MemoryStream memStream = new MemoryStream(); StreamWriter sw = new StreamWriter(memStream); sw.Write(dt); con.Open()...

8
голосов
4ответов
710 просмотров

How do I deserialize old data for a type that has changed?

I have data that has been stored using binary serialization for the following class: [Serializable] public abstract class BaseBusinessObject { private NameValueCollection _fieldErrors = new NameValueCollection(); protected virtual NameValueCollection FieldErrors { get { retu...

50
голосов
5ответов
33245 просмотров

What are the differences between the XmlSerializer and BinaryFormatter

I spent a good portion of time last week working on serialization. During that time I found many examples utilizing either the BinaryFormatter or XmlSerializer. Unfortunately, what I did not find were any examples comprehensively detailing the differences between the two. The genesis of my curio...

5
голосов
2ответов
6187 просмотров

десериализация универсального списка возвращает ноль

Я де / сериализую объект следующим образом: public class myClass : ISerializable { public List<OType> value; public myClass(SerializationInfo info, StreamingContext context) { this.value = (List<OType>)info.GetValue("value", typeof(List<OType>)); } void ISeri...