Error While Calling "Prepare" Function
When I call Prepare function after calling RegisterData, it crashes & give me the following message.
Error : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
StackTrace: at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
at FastReport.Table.TableRowCollection.get_Item(Int32 index)
at FastReport.Table.TableBase.CalcHeight()
at FastReport.BandBase.CalcHeight()
at FastReport.Engine.ReportEngine.PrepareBand(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.ShowBandToPreparedPages(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.ShowBand(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.ShowBand(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.StartFirstPage()
at FastReport.Engine.ReportEngine.RunReportPage(ReportPage page)
at FastReport.Engine.ReportEngine.RunReportPages()
at FastReport.Engine.ReportEngine.RunReportPages(ReportPage page)
at FastReport.Engine.ReportEngine.Run(Boolean runDialogs, Boolean append, ReportPage page)
at FastReport.Report.Prepare(Boolean append)
at FastReport.Report.Prepare()
I'm using version: 1.8.40.0
Error : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
StackTrace: at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
at FastReport.Table.TableRowCollection.get_Item(Int32 index)
at FastReport.Table.TableBase.CalcHeight()
at FastReport.BandBase.CalcHeight()
at FastReport.Engine.ReportEngine.PrepareBand(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.ShowBandToPreparedPages(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.ShowBand(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.ShowBand(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.StartFirstPage()
at FastReport.Engine.ReportEngine.RunReportPage(ReportPage page)
at FastReport.Engine.ReportEngine.RunReportPages()
at FastReport.Engine.ReportEngine.RunReportPages(ReportPage page)
at FastReport.Engine.ReportEngine.Run(Boolean runDialogs, Boolean append, ReportPage page)
at FastReport.Report.Prepare(Boolean append)
at FastReport.Report.Prepare()
I'm using version: 1.8.40.0
Comments
There was founded a solution for this issue? I have a similar error with an C# .Net application. In my case, I need to export as a txt file before printing. Here is the source code:
using (fast.Report report = new fast.Report())
{
report.Load(rutaReporte);
report.Dictionary.RegisterData(conjuntoDatos, nombreDataset, true);
report.ReportInfo.Name = nombreDocumentoGenerar;
report.Prepare();
// some extra code
using (TextExport export = new TextExport())
{
export.SetReport(report);
export.PrintAfterExport = true;
export.PrinterName = "MyMatrixPrinter";
export.PageBreaks = false;
export.Encoding = Encoding.GetEncoding(1200);
export.EmptyLines = true;
export.Frames = false;
export.ScaleX = 1.0;
export.ScaleY = 1.10;
export.Export(report, rutaExportacionReporte);
}
// some extra code
}
This code is within a loop, and the number of documents going to print is of about 500, but for about 5 documents it is thrown this error:
System.ObjectDisposedException: Cannot access a disposed object.
ObjectName: 'ProgressForm'.
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
// many many lines with the same message
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at FastReport.ReportSettings.OnStartProgress(Report report)
at FastReport.Engine.ReportEngine.Run(Boolean runDialogs, Boolean append, Boolean resetDataState, ReportPage page)
at FastReport.Report.Prepare(Boolean append)
at FastReport.Report.Prepare()
at //My source code
I'm using FastReport.Net v2018.1.6. Thakns in advance.
Greetings
Daniel Miranda
try to shut-off progress window:
FastReport.Utils.Config.ReportSettings.ShowProgress = false;
Exactly, this is a background process (a windows service indeed) which uses Parallel.Foreach to execute the early code in palallel (for instance "3 threads", each one for one printer) for a total of about 1500 documents. Here is some extra source code:
Parallel.ForEach(listaImpresorasPuntoEmision,
new ParallelOptions
{
MaxDegreeOfParallelism = cantidadImpresorasADD,
CancellationToken = cancelationTokenSource.Token
},
//early source code
);
Adding FastReport.Utils.Config.ReportSettings.ShowProgress = false; seems to solve the problem; after several tests the error has not been thrown anymore.
Thanks a lot ipong!!
Greetings,
Daniel