By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,507 Members | 1,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,507 IT Pros & Developers. It's quick & easy.

Crystal Reports, C# and a random 100% CPU lockup

P: n/a
**Using Visual Studio 2005 and Crystal Reports XI Release 2 Developer
Edition.

I currently have a multi-threaded C# application that loads a Crystal
Report at runtime, fills out the necessary parameters and then exports
the file to disk.

I export around 5000 reports a day, in about 3 hours (nightly runs of
the day's transactions), but sometimes, without warning or any debug
info, the application locks-up using 100% of the processor and becomes
completely unresponsive. No more reports are loaded or exported.

***It is soo unresponsive that if i actually click 'PAUSE' in visual
studio, my processor continues to use 100% of the cpu.*** (only time I
have ever seen this) I know Crystal Reports has some legacy COM
objects, and I have been doing research on COM Interop functions, but
nothing has helped.

I have run out of options at this point. Like I said, it doesn't
always happen, it isn't any report in particular, but I would say at
least 1/3 of the time the process will go to 100% CPU utilization
before it completes all 5000 reports. I have let it run for 30 minutes
in hopes it will get out of whatever loop it is stuck inside, but it
never does. Normally reports take about 10 seconds to export, so 30
minutes is a good indication it has locked up.

Then I get the enjoyment of starting the program all over again and
explaining to my boss why I shouldn't be fired :(

I would even accept 'unsafe' code at this point, i need to KILL
whatever is using 100% of my processor and RELOAD without restarting
the entire process.

Here is the segment which exports the report:
try
{
// clone the report from the global array (loaded individually
before, but still caused
// random 100% cpu usage)
reportDoc = (ReportDocument)config.RPTS[counter].Clone();
reportDoc.SetParameterValue("SETTDATE", DATE);

// setup parameters
reportDoc.SetParameterValue("RT", this.DDName);
reportDoc.SetDatabaseLogon(config.DSNUserName,
config.DSNPassword);

// SetupExportOptions simply defines a text file with 16
characters per inch output
ExportOptions exportOpts = SetupExportOptions(counter);
reportDoc.Export(exportOpts);
}
catch (ThreadAbortException threadAbortException)
{
//Do Nothing, let it cycle its way back up the chain
}
catch (Exception e)
{
if (e.Message == "Database logon failed.")
{
Console.WriteLine(" Server Busy - Waiting to Retry ( " +
this.DDName + " - " + config.reports[counter].Substring(3, 4) + " )
");
continue;
}
Console.WriteLine("\n\nFailed in ExportReport: " + DDName + " -
" + e.ToString());
return;
}
reportDoc.Close();
reportDoc.Dispose();

Jun 26 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

How you load your reports?

Obviously the code you posted is inside a loop, how the loop looks like?
How you have your reports stored? as files?

I would load one report at a time, run it and then make sure I call Dispose
of any instance that implements IDisposable.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

<st**********@gmail.com> wrote in message
news:11**********************@b68g2000cwa.googlegr oups.com...
**Using Visual Studio 2005 and Crystal Reports XI Release 2 Developer
Edition.

I currently have a multi-threaded C# application that loads a Crystal
Report at runtime, fills out the necessary parameters and then exports
the file to disk.

I export around 5000 reports a day, in about 3 hours (nightly runs of
the day's transactions), but sometimes, without warning or any debug
info, the application locks-up using 100% of the processor and becomes
completely unresponsive. No more reports are loaded or exported.

***It is soo unresponsive that if i actually click 'PAUSE' in visual
studio, my processor continues to use 100% of the cpu.*** (only time I
have ever seen this) I know Crystal Reports has some legacy COM
objects, and I have been doing research on COM Interop functions, but
nothing has helped.

I have run out of options at this point. Like I said, it doesn't
always happen, it isn't any report in particular, but I would say at
least 1/3 of the time the process will go to 100% CPU utilization
before it completes all 5000 reports. I have let it run for 30 minutes
in hopes it will get out of whatever loop it is stuck inside, but it
never does. Normally reports take about 10 seconds to export, so 30
minutes is a good indication it has locked up.

Then I get the enjoyment of starting the program all over again and
explaining to my boss why I shouldn't be fired :(

I would even accept 'unsafe' code at this point, i need to KILL
whatever is using 100% of my processor and RELOAD without restarting
the entire process.

Here is the segment which exports the report:
try
{
// clone the report from the global array (loaded individually
before, but still caused
// random 100% cpu usage)
reportDoc = (ReportDocument)config.RPTS[counter].Clone();
reportDoc.SetParameterValue("SETTDATE", DATE);

// setup parameters
reportDoc.SetParameterValue("RT", this.DDName);
reportDoc.SetDatabaseLogon(config.DSNUserName,
config.DSNPassword);

// SetupExportOptions simply defines a text file with 16
characters per inch output
ExportOptions exportOpts = SetupExportOptions(counter);
reportDoc.Export(exportOpts);
}
catch (ThreadAbortException threadAbortException)
{
//Do Nothing, let it cycle its way back up the chain
}
catch (Exception e)
{
if (e.Message == "Database logon failed.")
{
Console.WriteLine(" Server Busy - Waiting to Retry ( " +
this.DDName + " - " + config.reports[counter].Substring(3, 4) + " )
");
continue;
}
Console.WriteLine("\n\nFailed in ExportReport: " + DDName + " -
" + e.ToString());
return;
}
reportDoc.Close();
reportDoc.Dispose();

Jun 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.