Disposing of object is necessary thing after the job is done, but we hardly take care of this fact. In recent scenario, it hardly mater any space consumption if we don’t dispose any object. But there are some cases where, if you ignore the disposition thing, your life could be hell.
One among them is when you are dealing with Crystal Report. I’ve Crystal Report in my project and for a year the report were running fine, until one day I got a mail from my client that suddenly all the report stopped working!
There was an error – CrystalReport Load Report Failed
It is a very common error that you can find in Report viewer and there are hundred and thousand of links to guide to you in the right direction for solving the problem. One of the most common is to tweaking your system registry. Go to,
HKEY_LOCAL_MACHINE\SOFTWARE\CRYSTAL DECISIONS\10.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit (Ver 13.0)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\PrintJobLimit (Ver 12.0)
‘PrintJobLimit ‘ is the number of print job the report viewer can handle simulteniously and the default is 75.
One option is that you can increase the number to handle more report at a time. But this is not a feasible solution as you don’t know how many reports your client is going to print. In my case the number of reports were greater than 1500 at a time.
Second is to turn off the limit, by setting the value to -1. This one is a effective solution if you have crystal report in your own machine, but changing the registry value in your clien’t server is not a good idea.
I Found the best way to avoid the situation, that is to simply dispose your report object once the work is done. This can be done in Page_Unload event.
private ReportDocument _objReportDocument;
protected void Page_Unload(object sender, EventArgs e)