FastReport
FastReport copied to clipboard
A registration event in the constructor throws an exception to the target of the call
In the following code I Ctrl+P, throwing an exception that 'the calling target has an exception'.
- I'll just comment ctor
Report.FinishReport+=_StartReport;code is ok.
Can you duplicate it and test it?
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Barcode;
using FastReport.Table;
using FastReport.Utils;
namespace FastReport
{
public class ReportScript
{
public ReportScript(){
ignoreParamter=new string[] { };
emptyStringToShow="/";
Report.FinishReport+=_StartReport;
}
private string emptyStringToShow;
protected string EmptyStringToShow {
get{
return emptyStringToShow;
}
set{
emptyStringToShow=value;
}
}
private bool isHandleString;
private bool isHandleCheckBox;
private string[] ignoreParamter;
protected bool IsHandleString {
get {
return isHandleString;
}
set {
isHandleString = value;
}
}
protected bool IsHandleCheckBox {
get {
return isHandleCheckBox;
}
set{
isHandleCheckBox = value;
}
}
protected string[] IgnoreParamter {
get {
return ignoreParamter;
}
set{
ignoreParamter = value;
}
}
protected virtual void _StartReport(object sender, EventArgs e)
{
if (IsHandleString)
{
HandleStringParamter(Report.Parameters);
}
if (IsHandleCheckBox)
{
HandleCheckBoxObjectUncheckedSymbol();
}
}
protected void HandleCheckBoxObjectUncheckedSymbol(){
foreach (Base obj in Report.AllObjects)
{
if (obj is CheckBoxObject && !IgnoreHandleParamter(obj.Name))
{
((CheckBoxObject)obj).UncheckedSymbol = UncheckedSymbol.Cross;//Minus:-;Cross:×
}
}
}
protected void HandleStringParamter(ParameterCollection paramters){
foreach (FastReport.Data.Parameter p in paramters)
{
if(p.Parameters.Count!=0){
HandleStringParamter(p.Parameters);
}else{
if (IgnoreHandleParamter(p.Name) && p.DataType == typeof(string) && string.IsNullOrEmpty(p.Value + ""))
{
p.Value = emptyStringToShow;
}
}
}
}
protected virtual bool IgnoreHandleParamter(string pName){
for (int i = 0; i < ignoreParamter.Length; i++)
{
if (ignoreParamter[i]==pName)
{
return true;
}
}
return false;
}
}
}
Hello!
I was able to reproduce this problem I informed the developers
Best regards Marat