Thanks for replying Brian.
I have been able to do as you said and kill off the session objects when no longer needed. However, I have come across something else. I understand that when the Crystal Report Viewer opens a report, it creates a temp .rpt file somewhere on the C drive. In my case it is in the following location:
C:\Documents and Settings\<<Computer Name>>\ASPNET\Local Settings\Temp
The problem is that this never seems to be cleaned up, and my folder had over 1500 temp .rpt files in it! Would calling Close and Dispose on the report document remove the temp reports from here?
I went down this avenue and got an idea from a post I'd seen about creating a factory class to keep track of all report objects created. My class is shown below:
public class ReportFactory
{
public static Hashtable reportTable = new Hashtable();
public static void CreateReport(string key, string path)
{
ReportDocument report = new ReportDocument();
report.Load(path);
reportTable.Add(key, report);
}
public static void CloseReport(string key)
{
((ReportDocument)reportTable[key]).Close();
((ReportDocument)reportTable[key]).Dispose();
reportTable.Remove(key);
}
}
In theory I should have all the report objects in one place, and destroy them as and when needed using CloseReport. This doesn't seem to work as expected, and the files are sometimes removed from the temp folder, but sometimes not. I am slightly confused, so any light you could shed on the matter would be greatly appreciated.
Edited by Dave P - 23 Aug 2007 at 4:55am