RDLViewer progress modal crashing asp.net web application

49 views
Skip to first unread message

morri...@gmail.com

unread,
Jun 7, 2020, 12:29:40 AM6/7/20
to myfyireporting
I am using the .Net libraries to generate reports as PDFs, which then get emailed. I am setting a query string and passing a parameter based on the Github examples.

My code works fine in VS 2019 but generates a fatal error on my AWS hosted web server. I believe the error is because of a progress modal generated by RDLViewer when using the rebuild() method or the saveas method(). Is there a way to suppress the progress modal?

The error message and my code are below.

thanks,

Morris

Error message:

System.InvalidOperationException
  HResult=0x80131509
  Message=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.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

My Code:

using fyiReporting.RDL;
using fyiReporting.RdlViewer;

       public static string CreateInvoicePDF(string invNum)
        {
            string drive = "C:";
            int dashPosition = invNum.IndexOf("-");
            string ldealer = invNum.Substring(0, dashPosition);
            //string reportTemplateDir = "C:\\Anchor\\Connect\\Connect\\Connect\\Templates\\" + ldealer + "\\Report\\";
            string reportTemplateDir = drive + "\\inetpub\\connect\\Templates\\" + ldealer + "\\Report\\";
            string reportFileName = "basic_invoice2.rdl";
            string reportFile = reportTemplateDir + reportFileName;
            MyStatic.WriteLogMessage("Connect", "errorlog", reportFile);
            //string invoiceDir = "C:\\Anchor\\Connect\\Connect\\Connect\\Statements\\" + ldealer + "\\";
            string invoiceDir = drive + "\\ConnectData\\Statements\\" + ldealer + "\\";
            string invoiceFileName = invNum + ".pdf";
            string invoiceFile = invoiceDir + invoiceFileName;
            MyStatic.WriteLogMessage("Connect", "errorlog", invoiceFile);
            string logoFileName = GetDealerLogoFileName(ldealer);
            //string logoDir = "C:\\Anchor\\Connect\\Connect\\Connect\\Images\\Logos\\";
            string logoDir = drive + "\\inetpub\\connect\\Images\\Logos\\";
            string logoFile;
            string lstatus;

            if (logoFileName == "Not Found")
            {
                logoFile = "";
            }
            else
            {
                logoFile = logoDir + logoFileName;
            }
            string querystring = "";
            try
            {
                Uri sourcefile = new Uri(reportFile);

                var reportSource = System.IO.File.ReadAllText(sourcefile.AbsolutePath);
                querystring = "SELECT * FROM InvoiceWithDetail WHERE InvoiceNum = '" + invNum + "'";
                RdlViewer rdlView = new RdlViewer();
                rdlView.SourceFile = sourcefile;
                rdlView.Report.DataSets["Data"].SetSource(querystring);
                var paramstring = "logo=" + logoFile;
                rdlView.Parameters = paramstring;

                rdlView.Rebuild();
                rdlView.SaveAs(invoiceFile, OutputPresentationType.PDF);
                rdlView.Dispose();
                lstatus = "success";
            }
            catch (Exception e)
            {
                lstatus = e.Message;

            }
            MyStatic.WriteLogMessage("Connect", "errorlog", lstatus);
            return lstatus;
        }

Peter Gill

unread,
Jun 7, 2020, 10:27:35 AM6/7/20
to myfyireporting
RdlViewer should only be used in desktop apps.

Take a look at
https://github.com/majorsilence/My-FyiReporting/wiki/Export-to-Pdf---No-GUI
for how you can export a report to pdf without any gui controls.

--
You received this message because you are subscribed to the Google Groups "myfyireporting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to myfyireportin...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/myfyireporting/f4831c08-3609-4d06-89b7-b8e19ae003a0o%40googlegroups.com.

James Murphy

unread,
Jun 8, 2020, 1:23:19 AM6/8/20
to myfyireporting
Hi Peter,

Thank you for the quick reply. I was able to adapt the example to modify my code as shown below.

I figured out how to alter the query string from code. However I can't figure out how to pass a parameter. Is there an example for that?

Thanks,

Morris

            string reportTemplateDir = drive + "\\inetpub\\connect\\Templates\\" + ldealer + "\\Report\\";
            string reportFileName = "basic_invoice2.rdl";
            string reportFile = reportTemplateDir + reportFileName;

                Uri sourcefile = new Uri(reportFile);

                var reportSource = System.IO.File.ReadAllText(sourcefile.AbsolutePath);
                querystring = "SELECT * FROM InvoiceWithDetail WHERE InvoiceNum = '" + invNum + "'";
                var rdlp = new RDLParser(reportSource);
                var r = rdlp.Parse();
                r.DataSets["Data"].SetSource(querystring);
                var paramstring = "logo=" + logoFile;
                r.RunGetData(null);
                var sg = new fyiReporting.RDL.OneFileStreamGen(invoiceFile, true);
                r.RunRender(sg, OutputPresentationType.PDF);


To unsubscribe from this group and stop receiving emails from it, send an email to myfyire...@googlegroups.com.

Kernel Klink

unread,
Jun 9, 2020, 7:54:18 AM6/9/20
to myfyireporting
Good Morning Morris,

Please see the following snippet to achieve that; I pulled this from multiple sections of code so it may not perfectly align, but it should be very close.

MemoryStreamGen ms = new MemoryStreamGen();
RDLParser rdlp = new RDLParser(xmlDoc);
rdlp
.Parse();
ProcessReport pr = new ProcessReport(rdlp.Report, ms);
HybridDictionary ReportParams = new HybridDictionary();
ReportParams.Add(paramName, value);
pr
.Run(ReportParams, OutputPresentationType.PDF);
return ms;


The Kernel
Reply all
Reply to author
Forward
0 new messages