I have a report object which I can generate PDF by calling report.Publish(fileName, fileType) method and it works fine. However I need another method where I can generate stream bytes[] or the object. I tried using following code but it shows error because Report object is not serializable. My code:
//convert report object to bytesbyte[] bytes = ObjectToByteArray(report);
private static byte[] ObjectToByteArray(object obj) { if (obj == null) return null; BinaryFormatter bf = new BinaryFormatter(); using (MemoryStream ms = new MemoryStream()) { bf.Serialize(ms, obj);//ERROR comes here return ms.ToArray(); } }
any help is appreciated.
Hello sarojanand@gmail.com,
The Infragistics.Documents.Reports.Report Report class is not serializable indeed.
A possible workaround would be creating your custom serializable class that inherits from Infragistics.Documents.Reports.Report Report class or use a third-party serialization library.
If the workaround options do not help, could you please provide some additional information about what you are trying to achieve with the method that generates stream bytes and I will try to find another solution to this issue.