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 :
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

  • edited 6:00PM
    Hello,

    I've tried your code, it works well.
    wrote:
    Funny thing is when i remove one Text Object from my report, evrything works fine
    What is the content of this Text object?
  • edited 6:00PM
    I think his data bound text contains "[" characters. Is there an escape sequence or do you have to set the brackets to something which nobody will input in any comment memo field?
  • edited 6:00PM
    Springy wrote: »
    I think his data bound text contains "[" characters. Is there an escape sequence or do you have to set the brackets to something which nobody will input in any comment memo field?
    I thought that was the problem, but when i send datatable with no rows as datasource, so there can't be any data, or '' characters.
  • edited 6:00PM
    If you don't want expressions in the Text object, set its AllowExpressions property to false.
  • edited 6:00PM
    How do I bind it to data then?
  • edited 6:00PM
    Ok, if you want to bind it to data, forget my last message.
    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).
  • edited 6:00PM
    Hi Alex,

    what do I have to do if I want to use expressions and the "[" in the text?

    Best wishes
    Sascha
    AlexTZ wrote: »
    If you don't want expressions in the Text object, set its AllowExpressions property to false.
  • edited 6:00PM
    leSasch wrote: »
    what do I have to do if I want to use expressions and the "[" in the text?

    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.
  • edited 6:00PM
    It's TextObject.Brackets property.
  • edited 6:00PM
    I tired everything, setting bracekts property, setting AllowExpressions property, but still i get same exception, even
    when i send empty DataTable object, so error cannot be in data, column names don't have any special characters.
    Any more ideas.... >>>
  • edited 6:00PM
    Could it help calling GenerateReportAssembly(filename)? Maybe the resulting C# file (if generated at all) allows to spot the error more easily?
  • edited 6:00PM
    Toske,

    Could you make a simple project for me and send it to tz@fast-report.com?
  • edited 6:00PM
    I'll try with GenerateReportAssembly(); if can't find error myself, I'll send an simple project. Thnks in advance.
  • edited 6:00PM
    I found error in generated *.cs file ( thnks for reference to GenerateReportAssebly(), did'nt knew of existence of this function 'till now).
    Now, in report file, in Table1_ManualBuild function, there's for loop:
    for (int i = 0; i < colCount; i++)
    
    ,

    that's translated into
      for (int i = 0; i < colCount; i++)
    
    into generated assembly.
    I'll justr try to correct the error manually, add work with generated file, but is there any workaround for this?
  • edited 6:00PM
    I've tried to reproduce this, with no success.
    - 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
        private void ReportTitle1_BeforePrint(object sender, EventArgs e)
        {
          for (int i = 0; i < 20; i++);
        }
    

    Then I've saved the report as .cs class (File/Save as/CS file). Everything is correct.
  • edited November 2009
    I just found out that project that I'm working on uses older version(1.0.xx), that has this bug. When tried with FR.NET 1.2.x, it works just fine.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.