Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
415
how to generate stream/bytes from report using Infragistics.Documents.Reports.Report
posted

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 bytes
byte[] 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.

  • 1980
    Offline posted

    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.