Last post Dec 02, 2011 01:52 PM by desertfoxaz
Dec 02, 2011 01:52 PM|desertfoxaz|LINK
I have a legacy application (a web service) that uses Crystal Reports 8.5 report files. For legal reasons we cannot upgrade these files to a newer format so I have referenced the CRAXDRT.DLL to be able to work with these reports. They are kept in a database
and when needed, are extracted, written to disk, populated, printed, and then deleted from disk.
I can get them to print but for some reason, when I go to delete the file, I get an exception that says the file cannot be deleted because it is in use by another process. As a result, our server's disk space gets used up which kills the web service.
I've whittled my code down to the bare minimum and the following demonstrates when I can delete the report and when I cannot. I have two return statements. If I use the first and comment out the second, I can delete the file. However, if I comment out
the first, then call SetLogOnInfo, I cannot delete the file after the return statement is executed.
The caller of "Test" will delete the file at the "reportPath" once the Test method completes. This is where the exception occurs.
private void Test(string reportPath, string database, string username, string password)
ApplicationClass application = null;
Report report = null;
application = new ApplicationClass();
report = application.OpenReport(reportPath);
// Report can be deleted here
report.Database.Tables.SetLogOnInfo(database, database, username, password);
// Report cannot be deleted here
if (report != null)
report = null;
if (application != null)
application = null;
As far as I can tell, there is no method that allows me to close the report object.
In our application, there's a bit more happening after the SetLogOnInfo method is called, but it seems from this point the report is in a state where it cannot be deleted.
Any ideas? I haven't used COM objects in .NET too often but from what I can tell, the code in the finally block is what I am supposed to be doing when I'm done with them.