none
#Error in report when supplying a heterogenous set of objects RRS feed

  • Question

  • Hi,

    After providing a strong typed list<..> containing a heterogenous set of objects derived from a common base class, I might end up with '#Error' in the report.
    It turns out that depending on the actual type of the first object in the list the problem might or might not occur.

    After some digging in the ReportViewer assemblies I came across the following code:
      internal DataEnumerableReader(IEnumerable dataEnumerable)
      {
        this.m_dataEnumerator = dataEnumerable.GetEnumerator();
        if ((this.m_dataEnumerator != null) && this.m_dataEnumerator.MoveNext())
        {
          this.m_firstRow = true;
          this.m_row = this.m_dataEnumerator.Current;
          this.m_columns = TypeDescriptor.GetProperties(this.m_row);
        }
      }

    And then it is quite clear, why the problem occurs: The properties are taken from the first element in the list. The type used in the strong-typed list should be used instead, which is easily derived from 'dataEnumerable' using 'IsGenericType' and 'GetGenericArguments()' on the Type of 'dataEnumerable'.

    It seems to me this is a bug. My question for now is whether or not there is a workaround to fix it.
    Any help is very much appreciated.

    TIA, Jan.
    Saturday, January 9, 2010 11:35 PM

All replies

  • Hi Jan,

    Thanks for your post.

    It appears that the only way for you to workaround the issue is to convert your data source into same data type or to a data table.

    You can report the issue to http://connect.microsoft.com/ site. Thanks.



    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    See what's happening in MSDN forum? Follow us at Twitter.
    Tuesday, January 12, 2010 6:48 AM
    Moderator