{"id":7360,"date":"2014-06-07T02:36:12","date_gmt":"2014-06-07T02:36:12","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/report-viewer-object-with-nested-list-objects-collection-of-common-programming-errors\/"},"modified":"2014-06-07T02:36:12","modified_gmt":"2014-06-07T02:36:12","slug":"report-viewer-object-with-nested-list-objects-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/report-viewer-object-with-nested-list-objects-collection-of-common-programming-errors\/","title":{"rendered":"Report Viewer &#8211; Object With Nested List Objects-Collection of common programming errors"},"content":{"rendered":"<p>I have an existing class structure in place and want\/need to use that as a data source for a series of reports using vb and 2005, (though we are almost ready to move to 2010, so if that will solve this ill move today!)<\/p>\n<p>Using gotreportviewer sample for nested objects ive added a reportmanager class exposing a getdata method which ive populated with all my data and returned a list(of object). the data is there and correct at the point of databinding, i can add and reference top level properties, however not matter what syntax i try i cant reference the fields in nested classes\/lists. I get various messages ranging from &#8220;#Error&#8221; in the ouput field to nothing, to wont compile.<\/p>\n<p>my class structure is roughly this in short form:<\/p>\n<pre><code>Assembly0  \n   Class ReportManager  \n   TheData as List(Of Object)   \n   New() 'that populates TheData from the class structure below\n   GetData() as List(of Object)    \n\n   Assembly1  \n   Class Test  \n     aProperty1 as String  \n     aProperty2 as Int  \n     aProperty3 as String  \n     aProperty4 as String  \n     aProperty4 as List(of aType1)  \n\n   Assembly2   \n   Class AaType1  \n     aProperty1 as String  \n     aProperty2 as Int  \n     aProperty3 as String  \n     aProperty4 as String\n     aProperty4 as List(of aType2)   \n     aProperty4 as List(of aType3) \n     aProperty4 as String  \n\n   Assembly3  \n   Class aType2  \n     aProperty1 as Boolean  \n     aProperty1 as String  \n     you get the idea  \n\n   and so on.....  \n<\/code><\/pre>\n<p>in my main app<\/p>\n<pre><code>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  \n' Create an instance of our ReportManager Class  \nTry  \n   ' trust assemblies used in get data  \n    ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(Assembly.GetExecutingAssembly().Evidence)\n    ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(\"assy1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234\")\n    ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(\"assy2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234\")\n    ' etc through ALL dependant assemblies\n\n    ' create datamanager, that will populate its TheData property\n    Dim reportMan As Data.Reporting.Manager = New Data.Reporting.Manager(18) ' test id sent  \n\n    ' this is the method from the gotreportviewer sample, which only allows you to reference top level properties, regardless of syntax used. i.e. =Fields!Prop.Value.SubProp \n    ' doesnt work  \n    'ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource(\"DummyDataSource\", reportMan.GetData))  \n    'Me.ReportingDataBindingSource.DataSource = reportMan.GetData  \n\n\n    ' this is the only method i have found that allows me to reference an objects nested property and its fields.....?  \n    Data = reportMan.GetData()  \n    Me.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local  \n    Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource(\"Data_Reporting_ReportingData\", Data))  \n\n    ' fortnatley there is only ever one test in the list, HOWEVER there will be 4 specimens and n stages below that and so on.. \n    Dim SpecimenData As SpecimenList = Data(0).Specimens\n    Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource(\"Tests_Specimen\", SpecimenData))\n\n    ' so this method is no good either. currently only a test its just returning the first specimen.\n    'Dim StageData As Tests.Stages = Data(0).Specimens(0).Stages\n    'Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource(\"Tests_Specimen\", SpecimenData))\n\n    ' render report\n    Me.ReportViewer1.RefreshReport()\nCatch ex As Exception\n    MessageBox.Show(ex.Message)\nEnd Try\n<\/code><\/pre>\n<p>End Sub<\/p>\n<p>Fixes i found online\/googling:<\/p>\n<ul>\n<li>\n<p>You must add &#8220;ExecuteReportInCurrentAppDomain&#8221;, done that no difference.<\/p>\n<\/li>\n<li>\n<p>You must add Assembly: AllowPartiallyTrustedCallers() to AssemblyInfo.vb, No difference.<\/p>\n<\/li>\n<li>\n<p>You must strongly name you dependant assemblies, done that and it did get rid of an error regarding a call being made in the &#8220;Code&#8221; property of the report (for localization).<\/p>\n<\/li>\n<li>\n<p>have tried the =Fields!Property.Value.SubProperty syntax and it DOESNT work! no matter what variation i try.<\/p>\n<p>&#8216; in the rdlc &#8211; this syntax works for a top level properties<br \/>\n=Sum(Fields!TestVersion.Value, &#8220;Data_Reporting_ReportingData&#8221;)<\/p>\n<p>&#8216; using the alternate method list in the above code this works<br \/>\n=First(Fields!Index.Value, &#8220;Tests_Specimen&#8221;)<\/p>\n<p>&#8216; but these dont for its child properties =First(Fields!Specimens.Value.Index, &#8220;Data_Reporting_ReportingData&#8221;) =Fields!Specimens.Value.Index<\/p>\n<p>=Fields!Specimens.Value.Index.Value<\/p>\n<p>so does that mean im goin got have no choice but create something like Dim SpecimenData As Tests.SpecimenList = Data(0).Specimens for every single nested object? also for obvious reasons id rather not have to flatten the entire datastructure as its massive.<\/p>\n<\/li>\n<\/ul>\n<p>I have tried everything i can find on this, not much out there and everything points back to the same three four articles\/blog posts that just arent working for me, thier samples unmodified work, but none of them work when applied to nested lists or nested objects of inherited list types.<\/p>\n<p>Does anyone have any sample code of using objects with nested lists that actually works? as none of the ones i could find online work with anything but the simplest of scenarios. i.e. one assembly, or one code file or no nested lists or simple\/native types.<\/p>\n<p>ive been at this the best part of A WEEK! im now bald and stressed please help.<\/p>\n<p>Failing that can anyone suggest a thrid party vendor that does support this sort of thing? does crystal? pebble?<\/p>\n<p>appologies for the wall of text&#8230; Matma<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have an existing class structure in place and want\/need to use that as a data source for a series of reports using vb and 2005, (though we are almost ready to move to 2010, so if that will solve this ill move today!) Using gotreportviewer sample for nested objects ive added a reportmanager class [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7360","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7360"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7360\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}