This is a migrated thread and some comments may be shown as answers.

Object Reference not set to an instance of an object

1 Answer 705 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 30 Jul 2015, 08:05 PM

I'm having what appears to be a common problem, but I can't find a solution using what I'm seeing suggested by others. A report that previously worked in our software is now failing. We can't find any recent changes in source control, other than that there may be some cells that are filled with a null value that used to be guaranteed to be filled with a decimal. But even with that said, I can control to make sure that doesn't happen, and the error still occurs.

So, the issue is that when I click to create my report, it populates with an empty white window that says "Object Reference not set to an instance of an object".

In the output window of VS, the following is the top of the error:

An error has occurred while rendering the report: System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Reporting.Processing.Table.ForEachCell(Action`1 action)
   at Telerik.Reporting.Processing.Table.MeasureDataItemContent(IMeasureContext context, SizeRF availableClientSize)
   at Telerik.Reporting.Processing.DataItem.MeasureContent(IMeasureContext context, SizeRF availableClientSize)
   at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeRF availableSize)
   at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeRF availableSize)
   at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeRF availableSize)
   at Telerik.Reporting.Processing.LayoutElement.Measure(IMeasureContext context, SizeRF availableSize)
   at Telerik.Reporting.Processing.AbsolutePositionLayout.MeasureChildItems(IMeasureContext context, SizeRF availableClientSize)
   at Telerik.Reporting.Processing.AbsolutePositionLayout.MeasureContent(IMeasureContext context, SizeRF availableClientSize)
   at Telerik.Reporting.Processing.ReportSectionBase.MeasureContent(IMeasureContext context, SizeRF availableClientSize)
   at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeRF availableSize)
   at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeRF availableSize)
   at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeRF availableSize)

 

I'll post the designer file:

 

namespace CompanyNameABC.SoftwareNameXYZ.UI.Visuals.Reports
{
    partial class HistoricalQuoteReport
    {
        #region Component Designer generated code
        /// <summary>
        /// Required method for telerik Reporting designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            Telerik.Reporting.TableGroup tableGroup1 = new Telerik.Reporting.TableGroup();
            Telerik.Reporting.TableGroup tableGroup2 = new Telerik.Reporting.TableGroup();
            Telerik.Reporting.InstanceReportSource instanceReportSource1 = new Telerik.Reporting.InstanceReportSource();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HistoricalQuoteReport));
            Telerik.Reporting.Drawing.StyleRule styleRule1 = new Telerik.Reporting.Drawing.StyleRule();
            this.detail = new Telerik.Reporting.DetailSection();
            this.list1 = new Telerik.Reporting.List();
            this.panel1 = new Telerik.Reporting.Panel();
            this.subReport1 = new Telerik.Reporting.SubReport();
            this.pageHeaderSection1 = new Telerik.Reporting.PageHeaderSection();
            this.textBox104 = new Telerik.Reporting.TextBox();
            this.txtAgentInfo = new Telerik.Reporting.TextBox();
            this.pictureBox1 = new Telerik.Reporting.PictureBox();
            this.pictureBox2 = new Telerik.Reporting.PictureBox();
            this.HistoricalQuoteReportData = new Telerik.Reporting.ObjectDataSource();
            this.txtTitle = new Telerik.Reporting.TextBox();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            //
            // detail
            //
            this.detail.Height = Telerik.Reporting.Drawing.Unit.Inch(1.2000001668930054D);
            this.detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.list1});
            this.detail.Name = "detail";
            //
            // list1
            //
            this.list1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Inch(0.5D)));
            this.list1.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(Telerik.Reporting.Drawing.Unit.Inch(0.3999999463558197D)));
            this.list1.Body.SetCellContent(0, 0, this.panel1);
            tableGroup1.Groupings.Add(new Telerik.Reporting.Grouping(null));
            tableGroup1.Name = "DetailGroup";
            this.list1.ColumnGroups.Add(tableGroup1);
            this.list1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.panel1});
            this.list1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0D), Telerik.Reporting.Drawing.Unit.Inch(0D));
            this.list1.Name = "list1";
            tableGroup2.Name = "ColumnGroup";
            this.list1.RowGroups.Add(tableGroup2);
            this.list1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.5D), Telerik.Reporting.Drawing.Unit.Inch(0.3999999463558197D));
            this.list1.NeedDataSource += new System.EventHandler(this.list1_NeedDataSource);
            //
            // panel1
            //
            this.panel1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.subReport1});
            this.panel1.Name = "panel1";
            this.panel1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.5D), Telerik.Reporting.Drawing.Unit.Inch(0.3999999463558197D));
            //
            // subReport1
            //
            this.subReport1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0D), Telerik.Reporting.Drawing.Unit.Inch(0D));
            this.subReport1.Name = "subReport1";
            instanceReportSource1.ReportDocument = null;
            this.subReport1.ReportSource = instanceReportSource1;
            this.subReport1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.40000000596046448D), Telerik.Reporting.Drawing.Unit.Inch(0.3999999463558197D));
            //
            // pageHeaderSection1
            //
            this.pageHeaderSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(0.97011816501617432D);
            this.pageHeaderSection1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.textBox104,
            this.txtAgentInfo,
            this.pictureBox1,
            this.pictureBox2,
            this.txtTitle});
            this.pageHeaderSection1.Name = "pageHeaderSection1";
            //
            // textBox104
            //
            this.textBox104.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(2.5966284275054932D), Telerik.Reporting.Drawing.Unit.Inch(3.9401806134264916E-05D));
            this.textBox104.Name = "textBox104";
            this.textBox104.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(6.8000006675720215D), Telerik.Reporting.Drawing.Unit.Inch(0.15000000596046448D));
            this.textBox104.Style.Font.Bold = true;
            this.textBox104.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(8D);
            this.textBox104.Style.Font.Underline = true;
            this.textBox104.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Right;
            this.textBox104.Value = "Agent Information";
            //
            // txtAgentInfo
            //
            this.txtAgentInfo.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(2.5966284275054932D), Telerik.Reporting.Drawing.Unit.Inch(0.15628939867019653D));
            this.txtAgentInfo.Name = "txtAgentInfo";
            this.txtAgentInfo.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(6.8000006675720215D), Telerik.Reporting.Drawing.Unit.Inch(0.15000002086162567D));
            this.txtAgentInfo.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(8D);
            this.txtAgentInfo.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Right;
            this.txtAgentInfo.Value = "[Agent Info Here]";
            //
            // pictureBox1
            //
            this.pictureBox1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.0028777541592717171D), Telerik.Reporting.Drawing.Unit.Inch(3.9401806134264916E-05D));
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(2.2999999523162842D), Telerik.Reporting.Drawing.Unit.Inch(0.56999999284744263D));
            this.pictureBox1.Style.BackgroundImage.ImageData = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Style.BackgroundImage.ImageData")));
            this.pictureBox1.Style.BackgroundImage.MimeType = "image/png";
            this.pictureBox1.Style.BackgroundImage.Repeat = Telerik.Reporting.Drawing.BackgroundRepeat.NoRepeat;
            //
            // pictureBox2
            //
            this.pictureBox2.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(9.4299612045288086D), Telerik.Reporting.Drawing.Unit.Inch(3.9401806134264916E-05D));
            this.pictureBox2.Name = "pictureBox2";
            this.pictureBox2.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.56999999284744263D), Telerik.Reporting.Drawing.Unit.Inch(0.56999999284744263D));
            this.pictureBox2.Style.BackgroundImage.ImageData = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Style.BackgroundImage.ImageData")));
            this.pictureBox2.Style.BackgroundImage.MimeType = "image/png";
            //
            // HistoricalQuoteReportData
            //
            this.HistoricalQuoteReportData.DataSource = typeof(Silveus.Salestools.UI.Visuals.ViewModels.HistoricalQuoteVM);
            this.HistoricalQuoteReportData.Name = "HistoricalQuoteReportData";
            //
            // txtTitle
            //
            this.txtTitle.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.099999986588954926D), Telerik.Reporting.Drawing.Unit.Inch(0.699999988079071D));
            this.txtTitle.Name = "txtTitle";
            this.txtTitle.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(9.8000001907348633D), Telerik.Reporting.Drawing.Unit.Inch(0.22988177835941315D));
            this.txtTitle.Style.Font.Bold = true;
            this.txtTitle.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(14D);
            this.txtTitle.Style.Font.Underline = true;
            this.txtTitle.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center;
            this.txtTitle.Value = "[Title]";
            //
            // HistoricalQuoteReport
            //
            this.DataSource = this.HistoricalQuoteReportData;
            this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.detail,
            this.pageHeaderSection1});
            this.Name = "HistoricalQuoteReport";
            this.PageSettings.Landscape = true;
            this.PageSettings.Margins = new Telerik.Reporting.Drawing.MarginsU(Telerik.Reporting.Drawing.Unit.Inch(0.5D), Telerik.Reporting.Drawing.Unit.Inch(0.5D), Telerik.Reporting.Drawing.Unit.Inch(0.5D), Telerik.Reporting.Drawing.Unit.Inch(0.5D));
            this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Letter;
            this.Style.BackgroundColor = System.Drawing.Color.White;
            styleRule1.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
            new Telerik.Reporting.Drawing.TypeSelector(typeof(Telerik.Reporting.TextItemBase)),
            new Telerik.Reporting.Drawing.TypeSelector(typeof(Telerik.Reporting.HtmlTextBox))});
            styleRule1.Style.Padding.Left = Telerik.Reporting.Drawing.Unit.Point(2D);
            styleRule1.Style.Padding.Right = Telerik.Reporting.Drawing.Unit.Point(2D);
            this.StyleSheet.AddRange(new Telerik.Reporting.Drawing.StyleRule[] {
            styleRule1});
            this.Width = Telerik.Reporting.Drawing.Unit.Inch(10D);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
 
        }
        #endregion
 
        private Telerik.Reporting.DetailSection detail;
        private Telerik.Reporting.ObjectDataSource HistoricalQuoteReportData;
        private Telerik.Reporting.List list1;
        private Telerik.Reporting.Panel panel1;
        private Telerik.Reporting.SubReport subReport1;
        private Telerik.Reporting.PageHeaderSection pageHeaderSection1;
        private Telerik.Reporting.TextBox textBox104;
        private Telerik.Reporting.TextBox txtAgentInfo;
        private Telerik.Reporting.PictureBox pictureBox1;
        private Telerik.Reporting.PictureBox pictureBox2;
        private Telerik.Reporting.TextBox txtTitle;
    }
}

 If you already can help, that'd be fantastic. If you need to know more, I can explain more. Please help.
I'm using Q3 2013, btw.

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 03 Aug 2015, 04:14 PM
Hello Patrick,

The provided code snippet does not contain all settings. The List item is subscribed for its NeedDataSource event, where it is not clear what changes are included. In general, it is not recommended to modify the report definition once the data processing has started (in events) - Understanding Events.

Please test changing the approach where data is retrieved at run-time and then the List item is modified before passing the report instance to the viewer/ReportProcessor.


For example:
//get data
var data = GetData();
 
//get report instance
var report = new HistoricalQuoteReport();
 
//get the list item
var listItem1 = report.Items.Find("list1",true)[0] as Telerik.Reporting.List;
 
ModifyItemHere(listItem1, data);
 
//display the report
reportViewer1.ReportSource = new InstanceReportSource { ReportDocument = report };


I hope the provided information is helpful.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or