Compiler Exception
Hi everyone.
I have used some FastReport examples, i have report with TableObject named Table1, and following code
attached to it's ManualBuild Event :
In my C# application i have a following code:
when i run the code i have following exception:
I have same exception even when i send datatable without rows as Data Source.
Funny thing is when i remove one Text Object from my report, evrything works fine [img]style_emoticons/<#EMO_DIR#>/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> Here's contructor for PrintPreview class:[/img]
I have used some FastReport examples, i have report with TableObject named Table1, and following code
attached to it's ManualBuild Event :
DataSourceBase dSource = Report.GetDataSource("ReportTable");
      // init it
      dSource.Init();
     Â
      // number of columns in the datasource
      int colCount = dSource.Columns.Count;
     Â
      // print the table header which contains column titles. It's a row with index = 0.
      Table1.PrintRow(0);
      for (int i = 0; i < colCount; i++)
      {
        // fill the cell with column title
        Cell1.Text = dSource.Columns[i].Alias;
        // print it
        Table1.PrintColumn(0);
      }
     Â
      // now print a datasource content
      while (dSource.HasMoreRows)
      {
        // print the table body. It's a row with index = 1.
        Table1.PrintRow(1);
        for (int i = 0; i < colCount; i++)
        {
          string cellValue = dSource[dSource.Columns[i]].ToString();
          Cell2.HorzAlign = HorzAlign.Left;
          if(dSource.Columns[i].DataType==typeof(System.Decimal))
          {
            Cell2.HorzAlign = HorzAlign.Right;
          }
          else if(dSource.Columns[i].DataType ==typeof(System.DateTime))
          {
            Cell2.HorzAlign = HorzAlign.Left;
            cellValue = Convert.ToDateTime(cellValue).ToShortDateString();
          }
          else
            Cell2.HorzAlign = HorzAlign.Left;
         Â
          Cell2.Text = cellValue;
         Â
          // print it
          Table1.PrintColumn(0);
        }
       Â
        // move to the next row
        dSource.Next();
      }
In my C# application i have a following code:
  Report report = new Report();
  report.RegisterData(dt, "ReportTable");
  report.Load(Application.StartupPath + "\\Templates\\report.frx");
  this.addChildForm(new PrintPreviewReport(report));
when i run the code i have following exception:
FastReport.Utils.CompilerException: (23,58): error CS1026: ) expected
(23,76): error CS1525: Invalid expression term ')'
(24,28): error CS1026: ) expected
(24,40): error CS1525: Invalid expression term ')'
(33,38): error CS1026: ) expected
(33,43): error CS1002:; expected
(33,43): error CS1525: Invalid expression term ')'
(33,44): error CS1002:; expected
(46,40): error CS1026: ) expected
(46,45): error CS1002:; expected
(46,45): error CS1525: Invalid expression term ')'
(46,46): error CS1002:; expected
I have same exception even when i send datatable without rows as Data Source.
Funny thing is when i remove one Text Object from my report, evrything works fine [img]style_emoticons/<#EMO_DIR#>/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> Here's contructor for PrintPreview class:[/img]
        public PrintPreviewReport(FastReport.Report PreparedReport)
        {
            InitializeComponent();
            Cursor.Current = Cursors.WaitCursor;
            report1 = PreparedReport;
            report1.Preview = previewControl1;
            report1.Show();
            Cursor.Current = Cursors.Default;
        }
Comments
I've tried your code, it works well.
What is the content of this Text object?
Probably the problem is that you use non-existing data column in the Text object. In this case you'll get a bunch of compiler errors (invalid use of '', or something similar).
what do I have to do if I want to use expressions and the "[" in the text?
Best wishes
Sascha
I set the property "Marker" which normally is "[,]" to "<?[{,}]!>" for the column where I expect the user could potentially enter brackets. The designer recognized this when inserting new data columns in "Edit Text" window.
when i send empty DataTable object, so error cannot be in data, column names don't have any special characters.
Any more ideas....
Could you make a simple project for me and send it to tz@fast-report.com?
Now, in report file, in Table1_ManualBuild function, there's for loop:
,
that's translated into
into generated assembly.
I'll justr try to correct the error manually, add work with generated file, but is there any workaround for this?
- in the demo.exe, I edited the "Simple List" report
- I've created the BeforePrint event handler for the report title band
- in the code, I wrote
Then I've saved the report as .cs class (File/Save as/CS file). Everything is correct.