title: Error in exporting fastreport to pdf on asp.net c#
body: <p>I want to export <code>.frx</code> report that designed by <code>FastReport</code> as an pdf or excel file on a c# web form application like code below:</p>
  
  <pre><code>    public static bool ShowReport(string ReportFileName, DataTable ReportData, string DBObjectName, string ExportType, out string Message, params string[] AdditionalParams)
      {
          FastReport.Utils.Config.WebMode = true;
          string ReportFile = HttpContext.Current.Server.MapPath(WPResources.ReportsRoot) + string.Format("{0}_{1}.frx", ReportFileName, ExportType.ToUpper());
  
          FastReport.Report objReport = new FastReport.Report();
          objReport.Load(ReportFile);
          objReport.Dictionary.Connections.Clear();
          System.Data.DataTable resultTable = new DataTable();
  
          objReport.RegisterData(ReportData, DBObjectName);
          objReport.GetDataSource(DBObjectName).Enabled = true;
  
  
          int ParamsCount = AdditionalParams.Length;
          if ((ParamsCount % 2) != 0)
              ParamsCount--;
  
          for (int i = 0; i &lt; ParamsCount; i += 2)
          {
              var DynamicControl = (objReport.FindObject(AdditionalParams[i]) as FastReport.TextObject);
              if (DynamicControl != null)
              {
                  DynamicControl.Text = AdditionalParams[i + 1];
                  DynamicControl.Visible = !string.IsNullOrEmpty(AdditionalParams[i + 1]);
              }
          }
  
          (objReport.FindObject("rptData") as FastReport.DataBand).DataSource = objReport.GetDataSource(DBObjectName);
  
          string fileName = Path.GetFileNameWithoutExtension(ReportFile);
          fileName += "_" + WPFarsiDate.Today.ToString().Replace("/", ".") + "_" +
              DateTime.Now.Hour.ToString() + "." +
              DateTime.Now.Minute.ToString();
  
          if (ExportType == "Excel")
          {
              using (MemoryStream objMemoryStream = new MemoryStream())
              {
                  objReport.Prepare(false);
                  FastReport.Export.OoXML.Excel2007Export objExcel2007Export = new FastReport.Export.OoXML.Excel2007Export();
                  objExcel2007Export.OpenAfterExport = false;
                  objExcel2007Export.Export(objReport, objMemoryStream);
                  byte[] buffer = objMemoryStream.ToArray();
                  HttpContext.Current.Response.ClearHeaders();
                  HttpContext.Current.Response.Clear();
                  HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
                  HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("inline;filename={0}.xlsx", fileName));
                  HttpContext.Current.Response.BinaryWrite(buffer);
                  HttpContext.Current.Response.End();
              }
          }
          else if (ExportType == "Pdf")
          {
              using (MemoryStream objMemoryStream = new MemoryStream())
              {
                  objReport.Prepare(false);
                  FastReport.Export.Pdf.PDFExport objPDFExport = new FastReport.Export.Pdf.PDFExport();
                  objPDFExport.EmbeddingFonts = true;
                  objPDFExport.OpenAfterExport = false;
                  objPDFExport.Export(objReport, objMemoryStream);
                  byte[] buffer = objMemoryStream.ToArray();
                  HttpContext.Current.Response.ClearHeaders();
                  HttpContext.Current.Response.Clear();
                  HttpContext.Current.Response.ContentType = "application/octet-stream";
                  HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.pdf", fileName));
                  HttpContext.Current.Response.Clear();
                  HttpContext.Current.Response.BinaryWrite(buffer);
                  HttpContext.Current.Response.End();
  
              }
          }
  
          Message = string.Empty;
          return true;
      }
  </code></pre>
  
  <p>When I export it to excel, that is no any matter and it will be done successfuly. But when I export it to pdf, I get this error:</p>
  
  <blockquote>
    <p>Showing a modal dialog box or form when the application is not running
    in UserInteractive mode is not a valid operation. Specify the
    ServiceNotification or DefaultDesktopOnly style to display a
    notification from a service application.</p>
  </blockquote>
  
  <p>It should be noted that mentioned error just occurs in the main server and the job can be done successfully in localhost.
  It would be very helpful if someone could explain solution for this problem.</p>