Page 1 of 1

Error printing from asp.net process to invalid printer

Posted: Tue Mar 01, 2016 9:24 pm
by hfirst
Was debugging a new database, and printing wasn't working, then realized it was because I was sending the reports to an invalid printer. The printing is being executed from a background worker in an asp.net website to a server installed printer.

The error I am getting when I call print is:

Additional information: 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.

It would seem internally in your code you are trying to show a messagebox or something?. Is it possible for you to better support running guiless and just bubble up the real exception?

Re: Error printing from asp.net process to invalid printer

Posted: Wed Mar 02, 2016 8:49 am
by HighAley
Hello.

Could you specify how do you print the reports?
It seems that your message is corrupted.

Thank you.

Re: Error printing from asp.net process to invalid printer

Posted: Wed Mar 02, 2016 4:59 pm
by hfirst
A first chance exception of type 'System.InvalidOperationException' occurred in Stimulsoft.Report.dll

Additional information: 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.


CallStack:

at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Stimulsoft.Base.StiExceptionProvider.Show(Exception exception)
at Stimulsoft.Report.Print.StiPrintProvider.Print(StiReport report, Boolean showPrintDialog, Int32 fromPage, Int32 toPage, Int16 copies, PrinterSettings printerSettings)
at Stimulsoft.Report.StiReport.Print(Boolean showPrintDialog, Int32 fromPage, Int32 toPage, Int16 copies, PrinterSettings printerSettings)
at Stimulsoft.Report.StiReport.Print(Boolean showPrintDialog, PrinterSettings printerSettings)


Win 7-64, C#, 2016.1, IIS, asp.net 4.6.1

To duplicate, from within an asp.net background task started using HostingEnvironment.QueueBackgroundWorkItem, call report.Print(false, printerSettings); giving it an invalid printer name.

Re: Error printing from asp.net process to invalid printer

Posted: Thu Mar 03, 2016 11:45 am
by HighAley
Hello.

There is an Exception occurs while printing.
Please, try to set next property:

Code: Select all

StiOptions.Engine.HideExceptions = true;
Also you could use next code for logging:

Code: Select all

Stimulsoft.Report.StiLogService.LogEnabled = true;
StiLogService service = StiConfig.Services.GetService(typeof(StiLogService)) as StiLogService;
service.LogPath = "Report.log"; // Path and filename
Thank you.