I have a windows application project (C# and .NET 2.0) that used Crystal Report 2008. But I get error sometimes (it seems accidentally) in loading report. That error is:
Crystal Report Document needs to be manually disposed.
You should control the lifetime of all Reports in your application and call their Dispose before reaching the 75 limit.
There is a good approach on how to achieve this in this link:
http://geekswithblogs.net/technetbytes/archive/2007/07/17/114008.aspx
FYI, I have just verified this solution for a similar problem. The ReportDocument.Load method was failing when using a mapped network share or UNC path and installing the crystal reports VS runtime on the file server fixed the problem.
Increasing CurrentJobLimit
is not the solution; this number will be reached if the counter is not reset.
To avoid Job counter increase, you need to close the Crystal Report Document (ReportSource.Close()
) programmatically.
protected void Page_Unload(object sender, EventArgs e)
{
CrystalReportViewer1.ReportSource.Close();
}
This is the only way to avoid continue increasing of opened report, that are counted by CurrentJobLimit
The internet also suggests reinstalling the crystal report runtimes on the machines you are trying to open the report on (making sure that all locations have the same version).
If your application is a standalone executable then this error is generated because you are not closing your report object properly when you are done with whatever you do. You might see this error running in your application as an ASP.NET app with a lot of users accessing your site simultaneously.
You can cause the error to appear sooner by tweaking this registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\CRYSTAL DECISIONS\10.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit
It normally is defaulted to 75. For debugging you can set it to a smaller value and cause the error to appear sooner.
When you are done using a report object, call the .Close() method which will clean up the un-managed resources used.
There are those that mention to change the setting to -1. This is a mistake, it will only cause other problems for an application that is long running. The process will eventually run out of resources and start to fail in ways that will be even more difficult to troubleshoot.
I solved it, had the same issue. I went to report properties and set "buildAction" to "Content".