Skip to content

Scripting inside report #176

Description

@drechema

Hello,

I am running netcore 3 in Mac OSX

I made a simple report using Designer Community following documentation. The Script C# looks like this inside the .frx file:

<ScriptText>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
  {
    private void EstadoResultado_BeforePrint(object sender, EventArgs e)
    {
      if (((Int16)Report.GetColumnValue(&quot;demo&quot;)) &gt; 0) {
        Demo.TextColor = Color.Red;
      }
    }
  }
}
</ScriptText>

The report works fine in Preview from Designer Community.

I developed a simple Web API project using netcore 3.1 following one of your samples. The API use PDFSimpleExport to generate a PDF from report:

            report.Prepare();
            PDFSimpleExport pdf = new PDFSimpleExport();
            MemoryStream memStream = new MemoryStream();
            report.Export(pdf, memStream);

This code works perfectly with a report with no Scripting. But if I try with the before scripted report I have:

An unhandled exception has occurred while executing the request.
FastReport.Utils.CompilerException: (21,24): Error CS0012: The type 'Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
(21,36): Error CS0103: The name 'Color' does not exist in the current context

   at FastReport.Code.AssemblyDescriptor.InternalCompile()
   at FastReport.Code.AssemblyDescriptor.Compile()
   at FastReport.Report.Compile()
   at FastReport.Report.Prepare(Boolean append)
   at FastReport.Report.Prepare()

How can we add the reference to that assembly? How can we add the needed assembly referenced in the Report Script? Everything inside the Script is pure NetCore, I mean will run in any paltform?

Thanks

Metadata

Metadata

Labels

help wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions