2
Vote

System.ArgumentException

description

Hi. I'm trying to load custom data. I followed the sample exactly; except while creating report and loading data.
I have a data table already loaded with customers & their orders.
I'm looping into creating reports for each customer & creating report data for all orders of each customer.
But I'm getting an exception error while creating reports for more than one customer; report is created fine with only one customer data.
 
Error is:
 
System.ArgumentException: Specified Visual is already a child of another Visual or the root of a CompositionTarget.
at System.Windows.Media.VisualCollection.Add(Visual visual)
at CodeReason.Reports.ReportPaginator.GetPage(Int32 pageNumber)
at CodeReason.Reports.MultipleReportPaginator.GetPage(Int32 pageNumber)
at System.Windows.Xps.Serialization.DocumentPaginatorSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
at System.Windows.Xps.Serialization.DocumentPaginatorSerializer.SerializeObject(Object serializedObject)
at System.Windows.Xps.Serialization.XpsSerializationManager.SaveAsXaml(Object serializedObject)
at CodeReason.Reports.ReportDocument.CreateXpsDocument(IEnumerable`1 data)
at PTS.UserControl1.processSelectedRows() in C:\Users\Gopal\Documents\Visual Studio 2008\Projects\PTS\PTS\UserControl1.xaml.vb:line 173
 
 
Line 173 is: Dim xps As XpsDocument = reportDocument.CreateXpsDocument(listData)
 
I'm using Visual Basic 2008 Express Edition;
and DocumentViewer inside WPFUserControl inside ElementHost inside WindowsForm.
 
Please help me with this error.

file attachments

comments

stefanomasseroli wrote May 4, 2010 at 7:17 AM

The same for me!!! And there's no way out.. (it's impossibile to determine if the report will run), only this:

bool launched = false;
int fails = 0;
while (!launched)
 try {
       document = reportDocument.CreateXpsDocument(documentData); 
        launched = true; }
 catch (ArgumentException) { launched = false; fails++; }
 Console.WriteLine(String.Concat("XPS document creation fails: ", fails));
...so not properly the best programming way !! :-(

wrote May 4, 2010 at 7:18 AM

wrote Dec 15, 2011 at 8:32 AM

anshancuishi wrote Dec 15, 2011 at 8:35 AM

modify file"MultipleReportPaginator.cs" ,line 69:
if (pageNumber == 0 || (pageNumber - currentPage < _firstPages.Count)) dp = _firstPages[paginatorIndex]; else dp = pagePaginator.GetPage(pageNumber - currentPage);

mikedepo wrote Jul 12, 2012 at 5:33 AM

@anshancuishi
if I try your code
--->
modify file"MultipleReportPaginator.cs" ,line 69:
if (pageNumber == 0 || (pageNumber - currentPage < _firstPages.Count)) dp = _firstPages[paginatorIndex]; else dp = pagePaginator.GetPage(pageNumber - currentPage);
<---

when generating multiple reports document, the documents with more than one page become the same page repeated the number of time this report have pages.

anshancuishi wrote Aug 9, 2012 at 7:48 AM

@mikedepo
Yes, modify existing problem of backwardness you say, I'm sorry, need to find another way

wrote Feb 21, 2013 at 10:38 PM