on 09-23-2008 12:26 AM
Hi There,
I have two questions about this error.
1) How do you get rid of it after it happened. I had to reboot.
2) What's the best way to dispose of the reportdocument object.
I tried the code below, but it doesn't work:
protected void Page_UnLoad(object sender, EventArgs e)
{
rdoc.Close();
rdoc.Dispose();
GC.Collect();
}
Thanks for help on previous issues.
Paul O
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can try increasing your print job limit. The default 75 jobs was chosen because it provided the best results with best server performance. Increasing this number can degrade server performance.
- Open the registry editor by going to Start > Run. Then type in regedit.exe and click Ok.
- Find this key HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.5\Report Application Server\InprocServer\PrintJobLimit
- Increase the print job limit. You may want to try something like 125 or 150
Keep in mind this may only delay the error you are getting. If you are not cleaning up correctly then you'll just get the error at a later time.
Your clean up code looks okay as long as you are not putting your ReportDocument in session. I would need to know more about your code before I can say if it is correct or not.
- Where are you loading your ReportDocument?
- Are you putting the ReportDocument in Session or Cache?
- What "doesn't work" with the code you posted? Do you get the same error or a new one?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for both replies.
I don't have the opportunity to change the registry on the server. The Page_Unload code seems to be the key. The problem is when I click next page I get the error:
"Object reference not set to an instance of an object." above the report viewer.
Here's my Page_Init:
protected void Page_Init(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ScriptManager mstScriptManager;
mstScriptManager = (ScriptManager)Master.FindControl("ScriptManager1");
mstScriptManager.RegisterPostBackControl(CRViewer);
}
//pbo 9/19/2008
if (this.Page.IsPostBack)
{
if (Session.Contents["rdoc"] != null)
{
//added sap suggesion
rdoc = (ReportDocument)Session.Contents["rdoc"];
CRViewer.ReportSource = rdoc;
}
}
}
I load the report in Page_Load, but do not reload it when on postback:
if (reportType == "ALL" & !IsPostBack)
{
rdoc = (ReportDocument)Session["rdoc"];
if (rdoc == null)
{
rdoc = new ReportDocument();
}
else
{
rdoc.Close();
rdoc.Dispose();
rdoc = new ReportDocument();
}
reportPath = Server.MapPath("reportNamerpt");
rdoc.Load(reportPath);
rRisksTableAdapters.Risks_ALLTableAdapter cta = new rRisksTableAdapters.Risks_ALLTableAdapter();
rdoc.SetDataSource((DataTable)cta.GetData(Convert.ToInt16(SessionManager.LOGGED_IN_USER_COMPANYID())));
rdoc.SetDatabaseLogon(ConfigurationManager.AppSettings["username"].ToString(), ConfigurationManager.AppSettings["pwd"].ToString());
Session["rdoc"] = rdoc;
CRViewer.ReportSource = rdoc;
}
I think I am following all the standard stuff but am obviously missing something.
The problem is you've Closed and Disposed of your ReprotDocument in session. When you attempt to postback there is nothing there for the CrystalReportViewer to reference. In your case you need to clean up somewhere else. Try cleaning up in a button click event, or capture when your user closes the browser window and clean up the session vars.
You could also clean up in the global.asax file in the Session_End().
There is no way to find out how many jobs are in use as far as I know.
They have to time out if not cleaned up properly. The code snipped you posted looks good.
I have not see anyone use Session_OnEnd before so let us know if that does it and how you implemented it.
If it works it will help others with the same issue.
Typically you would have to use a button click or some such to force the clean up to fire.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.