Skip to Content
Former Member
Aug 19, 2011 at 03:38 PM

Unable to cast object to type 'FileStreamDeleteOnClose'


Good morning,

We have a three tier application, a desktop application that uses crystal viewer to view reports, a web service running on IIS which then talks to our database.

With our workstation install we deploy CRRuntime_12_2_mlb_f23.msi

Recently, we thought about updating our web service crystal runtime. The web service is in charge of Loading the report, and talking to the database to generate the report. The web service then passes the generated report with the data to the workstation. The workstation uses the crystal viewer to open the report with the data.

On the web service side we updated to Crystal Reports 2008 SP4 runtime. Now, when we open a report on the workstation, the workstation gets this error that comes from the web service

System.InvalidCastException: Unable to cast object of type 'FileStreamDeleteOnClose' to type 'System.IO.MemoryStream'. at Hdl.Prime.Service.PrimeWCFService.RunReport(Int32 repId, List'1 repParams, List'1 licenseIDs, Int32 storeImage)

We believe it is generating this error when our web service makes this call within the RunReport() method


MemoryStream mstream = (MemoryStream)crystalRep.ExportToStream(ExportFormatType.CrystalReport); 

It didn't used to make this error until we upgraded to the SP4 runtime on the web server.

Has anything changed with the ExportToStream call. Is it returning a different object type?

Thank you for your time in advanced