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

weird Crystal Reports exception

P: n/a
hi,
i am encountering a sporadic exception using crystal reports that is causing
me grief, I can't 'handle' it...
my code is loading a typed report, and loading a DataSet to it.
unfortunately crystal reports customer support is very poor and their 'case
management' tool refuses to function. i'm posting here in the hope that
someone may have seen it before and worked around it.

first of all, here is the exception:

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]
PEOpenPrintJobWithInfoW(* ) +0
CrystalDecisions.CrystalReports.Engine.ReportDocum ent.Load(String
reportName, OpenReportMethod openMethod, Int16 parentJob) +989
CrystalDecisions.CrystalReports.Engine.ReportClass .Load(String
reportName, OpenReportMethod openMethod, Int16 parentJob) +457
CrystalDecisions.CrystalReports.Engine.ReportDocum ent.-() +98
CrystalDecisions.CrystalReports.Engine.ReportDocum ent.get_DataDefinition()
+7
CrystalDecisions.CrystalReports.Engine.ReportDocum ent.SetParameterValue(String
name, Object value) +70
DocuSee.Report.Page_Load(Object sender, EventArgs e) +1872
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750

as you can see, it is an internal CR exception, not caused directly by my
own code.
i checked all the basics, it is a perfectly valid dataset being used. also,
i don't have problems with other crystal reports using this same loading
technique.

here is my code:
Reports.crProducerApplicationForm rpt = new
Reports.crProducerApplicationForm();
rpt.SetDataSource(ds);
ExportCrystalReportToPDF(rpt, "Producer_Application.pdf");

and here is the ExportCrystalReportToPDF function

/// <summary>
/// Convert the Report to PDF and write to the HTTP response
/// </summary>
/// <param name="rpt">The report object</param>
/// <param name="filename">Should include include .pdf</param>
public static void
ExportCrystalReportToPDF(CrystalDecisions.CrystalR eports.Engine.ReportClass
rpt, string filename)
{
MemoryStream stream =
(MemoryStream)rpt.ExportToStream(CrystalDecisions. Shared.ExportFormatType.PortableDocFormat);
byte[] bytes = new Byte[stream.Length];
stream.Read(bytes, 0, (int)stream.Length);
stream.Close();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer= true;
response.ContentType = "application/pdf";
response.AddHeader("Content-Disposition", "inline;filename=\"" + filename
+ "\"");
response.BinaryWrite(bytes);
response.End();
}
i have tested it with several different versions of acrobat, and it seems to
be completely on the server side where the error is happening. occassionally
when it does work, i have noticed incorrect download progress in the IE
status bar (when Acrobat is embedded), e.g. "downloaded 1.1Gb of 2.0Gb",
when the PDF is only a few K big.

the report itself is very simple, just displays fields and an image. it is
also 'up to date'.

it's quite a problem, so if anyone has any help, i would be extremly
grateful!
thanks
tim
Aug 29 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello Tim,

I'm not familiar with crystal report, as for the exception ,it seems
related to the report loading process, also I found that the report is
exposed to PDF stream, is the problem only occurs when you export the
report to PDF stream?

Also, you can try other simple report to see whether you can isolate the
issue and find some common characteristics on those problem reports?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.