Exception running report using report file and business object data - FastReport.Utils.CompilerExcep

I keep on getting the following exception in C# WinForm project with a very simple form and a button to display a report I have already designed.

An unhandled exception of type 'FastReport.Utils.CompilerException' occurred in FastReport.dll. Additional information: (AutoID): Error CS0103: The name 'CalibrationsView' does not exist in the current context. (SystemID): Error CS0103: The name 'CalibrationsView' does not exist in the current context. (DDate): Error CS0103: The name 'CalibrationsView' does not exist in the current context. (Volume): Error CS0103: The name 'CalibrationsView' does not exist in the current context. (Actual): Error CS0103: The name 'CalibrationsView' does not exist in the current context. (Delta): Error CS0103: The name 'CalibrationsView' does not exist in the current context. (ErrorMargin): Error CS0103: The name 'CalibrationsView' does not exist in the current context. (Multiplier): Error CS0103: The name 'CalibrationsView' does not exist in the current context. (Duration): Error CS0103: The name 'CalibrationsView' does not exist in the current context occurred.

My code behind the button is as follows:

    private void button1_Click(object sender, EventArgs e)
    {
      List<CalibrationModel> data = new List<CalibrationModel>();

      for (int i=0; i<5; i++)
      {
        CalibrationModel c = new CalibrationModel();
        c.AutoID = i;
        c.SystemID = "ID" + i.ToString();
        c.DDate = DateTime.Now.ToLocalTime().ToString();
        c.Volume = i;
        c.Actual = i;
        c.Delta = i;
        c.ErrorMargin = i;
        c.Duration = i;
        c.Speed = i;
        c.Notes = "Test " + i;

        data.Add(c);
      }

      using (Report CReport = new Report())
      {
        CReport.Load("CReport.frx");
        CReport.RegisterData(data, "CalibrationsView", FastReport.Data.BOConverterFlags.AllowFields, 1);
        DataBand d = (DataBand)CReport.FindObject("Data1");
        d.DataSource = CReport.GetDataSource("CalibrationsView");
        CReport.Show();
      }
    }

The report exists, not sure what I am missing as the exception is encountered on the CReport.Show() line???

Thanks,

Sam.

Comments

  • Hello!

    Before calling `report.Prepare()`, you must carry out the following:

    report.Load(‘YourReport.frx’);
    report.RegisterData(calibrationsList, ‘CalibrationsView’, maxNestingLevel: 3);
    var ds = report.GetDataSource(‘CalibrationsView’);
    if (ds != null) ds.Enabled = true;
    report.Prepare();
    

    Also, open the .frx file in a text editor and check the exact values of Name="..." and ReferenceName="..." within the <BusinessObjectDataSource> element; they must match the second parameter of RegisterData character for character.

This discussion has been closed.