Maximum report processing jobs limit issue in Crystal Report

This is a very common error in Crystal Report when its give this following message.
"The maximum report processing jobs limit configured by your system administrator has been reached."
I have been read about its on lot forums and new groups. Its actually means that Crystal Report print job limit has been reached and you should handle this problem by increasing the job limit in the registry. The basic reason of this problem is Garbag Collector (GC) cannot clear the reference of report document in their collection process its only clear report viewer.
**HKEY_LOCAL_MACHINE\SOFTWARE\CRYSTAL DECISIONS\10.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit
**Yesterday we also facing this problem in our application and after lot of discussion in the team we find out a good solution of this problem in the form following factory class because we not facing this problem in whole application.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;

namespace Test.Utilities
{
    public class ReportFactory
    {
        protected static Queue reportQueue = new Queue();

        protected static ReportClass CreateReport(Type reportClass)
        {
            object report = Activator.CreateInstance(reportClass);
            reportQueue.Enqueue(report);
            return (ReportClass)report;
        }

        public static ReportClass GetReport(Type reportClass)
        {

            //75 is my print job limit.
            if (reportQueue.Count > 75) ((ReportClass)reportQueue.Dequeue()).Dispose();
            return CreateReport(reportClass);
        }
    }
}

You can use this ReportFactory class for creating ReportClass object and don’t need to call explicitly dispose method on the page because ReportFactory class will automatically dispose it when count reach to 75.

This article is part of the GWB Archives. Original Author: Saqib Ullah

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.