469,946 Members | 1,787 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

weird Crystal Reports exception

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
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()
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

here is my code:
Reports.crProducerApplicationForm rpt = new
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);
HttpResponse response = HttpContext.Current.Response;
response.Buffer= true;
response.ContentType = "application/pdf";
response.AddHeader("Content-Disposition", "inline;filename=\"" + filename
+ "\"");
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
Aug 29 '06 #1
1 2076
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?


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.

Similar topics

3 posts views Thread by Richard Hallgren | last post: by
2 posts views Thread by Mythran | last post: by
1 post views Thread by Islam Elkhayat | last post: by
3 posts views Thread by Milan Todorovic | last post: by
2 posts views Thread by Diogo Alves - Software Developer | last post: by
2 posts views Thread by Code Monkey | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.