none
VS2010 Report Designer - Object reference not set to an instance of an object. RRS feed

  • Question

  • Hello all,

    I'm currently working on developing a web application that makes use of several libraries full of custom classes. I am trying to design client-side reports based on these classes(RDLC files) in VS2010.

    The problem is that every time I create a report and click New -> Dataset... and attempt to add a new data source from an object. I can see my libraries and select my objects, but when I select an object and click Finish, I get the error "Object reference not set to an instance of an object." The Dataset is not added to the report, however the DataSource folder has a new file called MyClassObject.datasource in it. Then, unless I delete that file, I cannot even attempt to add other data sources to my report file.

    The error is not consistent with all of my class objects (all of which are identical except for different Fields/Properties), it only does it some of the time, and I can't pinpoint any regularity to it. Nothing seems to fix the problem, but hand-typing an identical new class object and then creating a new report from scratch will sometimes solve the problem.

    No amount of cleaning, rebuilding, or the usual tricks seems to work to solve this problem. The only solution I have is to open the RDLC file as text and manually edit the XML between the <DataSets></DataSets> tag to add the fields manually.

    I would really like to know if this is a bug with a possible workaround, or if I am missing something important in my design. here's a sample of what the class objects look like (BaseObject and BaseList<> are custom derivatives of Object and List<> with common fields and functions):

    Thanks,
    Adam

    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Data.SqlTypes;
    using System.Collections.Generic;

    namespace My_Library
    {
       [Serializable]
       public class MyClassObject : BaseObject, IDisposable
       {
          //Constructor
          public MyClassObject() {}
          //Fields
          private string _FieldOne = "";
          private string _FieldTwo = "";
          //Properties
          public string FieldOne
          { get { return _FieldOne; } set { _FieldOne = value; } }
          public string FieldTwo
          { get { return _FieldTwo; } set { _FieldTwo = value; } }
          public string FieldThree
          { get { return _FieldThree; } set { _FieldThree = value; } }
          //Functions
        
          //Dispose
          public void Dispose()
          { GC.SuppressFinalize(this); }
       }

       [Serializable]
       public class MyClassObjectList : BaseList<MyClassObject>, IDisposable
       {
          //DatabaseReader Functions

          //Dispose
          public void Dispose()
          { GC.SuppressFinalize(this); }
       }
    }


    • Edited by Silound Monday, June 11, 2012 7:38 PM Edited to add code
    Monday, June 11, 2012 7:35 PM

All replies

  • To those who also happened to get this issue, make sure that all of your projects Platform Targets are set to Any CPU. That's the only fix that has worked for me. I do hope this fix works for you as well.
    Monday, July 11, 2016 7:33 AM