3

我有一个 Telerik Report 项目,它在ReportProcessor.RenderReport("PDF", reportToExport, null);方法的某处抛出 NullReferenceException。我得到以下堆栈跟踪:

System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Reporting.Processing.Table.MeasureColumns(Graphics graphics)
at Telerik.Reporting.Processing.Table.Measure(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ProcessingElement.Measure(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ReportSectionBase.Measure(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.Group.MeasureElement(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.Report.MeasureElement(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ProcessingElement.Measure(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ProcessingElement.Measure(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ReportSectionBase.Measure(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.Group.MeasureElement(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.Report.MeasureElement(MeasureDirection dir, Graphics graphics)
at Telerik.Reporting.Processing.Report.MeasureElement(ProcessingElement elementToMeasure)
at Telerik.Reporting.Processing.ReportProcessor.RenderCore(String format, IList`1 reports, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRender(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRenderStateless(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo)
at JIIGCAL.CareerCompass.Reports.Views.ReportsDefault.ExportToPDF(IReportDocument reportToExport) in C:\dev\.....\Reports\Viewer.aspx.cs:line 236

Viewer.aspx.cs 中的第 236 行是对 RenderReport() 的调用;我不知道如何追踪这个错误。有没有办法为运行时报告引擎启用日志记录,以便我可以获得更多关于哪个字段/列/表是有问题的信息?

编辑:找到解决方案

收到 Telerik 的以下回复:

如果表格单元格中的文本框的大小设置为零,则可能会发生此类错误。将大小从零更改为非常小的值将解决问题。请注意,将行/列组设置为零大小会将它们设置为 Visible=false,这是不受支持的。由于 CrossTab/Table 的数据驱动特性,当您想要隐藏某些数据时,您需要过滤 CrossTab 组而不是隐藏它们。

我根据某些条件将几个文本框设置为 Visible=false。我改变了这个,它工作得很好。

至于如何记录内部运行时引擎的结果,他们给出了以下建议:

使任何 .NET 应用程序能够输出一些日志的标准方法是使用跟踪侦听器。例如,您可以将 TextWriterTraceListener 添加到应用程序的配置文件中:

<configuration>
  <system.diagnostics>
    <trace autoflush="false" indentsize="4">
      <listeners>
        <add name="myListener"
          type="System.Diagnostics.TextWriterTraceListener"
          initializeData="TextWriterOutput.log" />
        <remove name="Default" />
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>

我们在报告引擎中使用相同的方法。您可以在 Visual Studio 输出窗口中看到我们所做的一些跟踪,也可以下载产品源代码以供参考。

4

0 回答 0