Reputation: 255
I want to serialize a ReportDocument using XML serialization but in vain, that's my code:
public String serialiser (ReportDocument rd)
{
StringWriter sw= new StringWriter();
System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(ReportDocument));
xs.Serialize(sw, rd);
return sw.ToString();
}
NB: CrystalDecisions.CrystalReports.Engine.ReportDocument.
I got the following error:
An error occurred during the reflection of the type 'CrystalDecisions.CrystalReports.Engine.ReportDocument'.
How could I serialize it?!
Upvotes: 0
Views: 1671
Reputation: 7054
My guess is that type is not marked as serializable. Have you tried doing binary serialization?
public static byte[] SerializeToBytes<T>(T original)
{
byte[] results;
using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(stream, original);
stream.Seek(0, SeekOrigin.Begin);
results = stream.ToArray();
}
return results;
}
Upvotes: 1