I have a class like this:
public class Data
{
public string Name { get; set; }
public int Size { get; set; }
public string Value { get; set; }
[NonSerialized] public byte[] Bytes;
}
When a List<Data>accesses the serialization method below, it sometimes dies with
InvalidOperationException "This XmlWriter does not support base64 encoded data."
As you can see, I am not coding anything, just using the default serialization mechanism.
private static XDocument Serialize<T>( T source )
{
var target = new XDocument( );
var s = new XmlSerializer( typeof( T ) );
using( XmlWriter writer = target.CreateWriter( ) )
{
s.Serialize( writer, source );
}
return target;
}
The data will have properties Namethat are English words, separated by underscores. The property Valuewill be similar, with the exception of the added mathematical operators or numbers (they are mathematical expressions).
Does anyone know what causes it and how can I fix it?
ยตBio