I was wondering if someone could give me some insight into an issue.
Currently, we have a Visual Studio 203 .NET Winforms application using the embedded Crystal Reports for .NET which produces reports which are presented as PDF files.
At times, an image associated with a report is read from a server and dynamically embedded in the report using the FileStream --> BinaryReader --> ReadBytes -- > insert into DataSet -- > set DataSet as DataSource in Crystal Report method.
This works just fine "most" of the time. However, once in a blue moon, the wrong image file is embedded in the report. This is extremely puzzling.
Please assume that the path to the file given to the FileStream is always correct and never the wrong path. Please assume that all the files are uniquely named.
Each time the report is generated, all the objects associated with the image reader and Crystal report are newly instantiated, closed, disposed, etc..
A typical scenario is that a user at a PC creates a report with a particular image associated with it. Later in the day, another user opens the application and creates a report with a different image associated with it, but when the PDF is presented to the screen, the image from the earlier report is on it. If the report is created again, the correct image is now on the report.
My question is how is this possible? Is the image cached? If so, where? The line of code which links the image to the dataRow of the dataSet is straightforward:
imageRow("EMBEDDED_IMAGE") = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length)).
Does the ReadBytes method store the ByteArray in some persistant memory location that is not getting destroyed?
Given that the image files must be read from a remote server, is there a more secure method to read and then destroy the byte array on the local PC, ensuring that it is not available again for use?
Any suggestions would be welcome.
Thank you for your time.