65.9K
CodeProject is changing. Read more.
Home

Problem of Crystal Reports When Not Closing Report Document Object

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.88/5 (7 votes)

Aug 6, 2007

CPOL

1 min read

viewsIcon

29394

This article is about Issue in Crystal report

Introduction

This article is about the space allocation problem that is caused by running Crystal reports in ASP.NET. It is about the files created in temp folder of system.

Background

I stuck with the problem of space in Windows temp folder for quite sometime when I was running Crystal reports in my ASP.NET application. Whenever I run a Crystal report, some files are loaded into my server temp (c:\windows\temp) folder. When that folder reaches a certain capacity, "Load Report Failed" error occurs. When I try to delete these files manually from temp folder, it gives an error notice:

"File cannot be deleted. It is being used by another person or program…." 

Using the Code

Whenever I run a Crystal report in my ASP.NET application, Crystal report file and some other files are created in temp folder. When that folder reaches a certain capacity, it gives "Load Report Failed" error.

When I try to delete those files manually from temp folder, they cannot be deleted and throw an error message:

"File cannot be deleted. It is being used by some other person or program.............." 

The only way to delete those files is to reboot the system and delete the files manually which is of course not the desired solution.

Finally, to resolve this problem, I have added the following line of code into the finally statement of the try catch block. This will automatically delete the files from temp folder.

// try {Use the report object and do load report etc.......} catch()
// {Handles exception here......} finally{NewReport.Close();} 

History

  • 6th August, 2007: Initial post