System.AccessViolationException while opening the printer dialog

Posted by: mario.wagner on 8 March 2020, 11:52 pm EST

  • Posted 8 March 2020, 11:52 pm EST

    Hello,

    we are using ActiveReports 13.1.16872.0 in our .NET Framework 4.7.2 application. The application is running on a lot PCs of our customers (> 1000) without problems. On one PC the application is shutting down immediately when the printer dialog is opening by calling the “Print” method of a SectionDocument. This happens not always but in 50% of the cases.

    The following .NET Framework exception is logged in the Windows event log:

    Framework Version: v4.0.30319

    Description: The process was terminated due to an unhandled exception.

    Exception Info: System.AccessViolationException

    at System.Drawing.SafeNativeMethods.DocumentProperties(System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef, System.String, IntPtr, System.Runtime.InteropServices.HandleRef, Int32)

    at System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal(System.String)

    at System.Drawing.Printing.PrinterSettings.GetHdevmode()

    at System.Drawing.Printing.PageSettings.get_PaperSource()

    at GrapeCity.ActiveReports.Viewer.Win.Controls.CustomPrintDialog.RunDialog(IntPtr)

    at System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window)

    at GrapeCity.ActiveReports.Viewer.Win.Printing.PrintImpl.#zs(#r0B.#q0B, System.Action

    1<System.Drawing.Printing.PrinterSettings>, Boolean)    at GrapeCity.ActiveReports.Viewer.Win.Printing.PrintImpl.Print(#r0B.#q0B, Boolean, Boolean, Boolean, Boolean, System.Action
    1<System.Drawing.Printing.PrinterSettings>)

    at GrapeCity.ActiveReports.PrintExtension.Print(GrapeCity.ActiveReports.Document.SectionDocument, Boolean, Boolean, Boolean, Boolean)

    It is a PC with a hole bunch of avaliable local and network printers. My guess is that one of the printer drivers is causing the problem while retrieving the printer settings. Windows is up to date and at least the printer driver of the default printer should be up to date to. If I switch the default printer to “PDF creator” the error still occurs.

    I wrote a test application (without ActiveReports) which called “System.Drawing.Printing.PrinterSettings.GetHdevmode()” for all of the printers. But it encounters no errors.

    Does anybody know the cause of the problem and how to solve it? How could we find the invalid printer if this is the cause?

    Thanks in advance!

  • Posted 10 March 2020, 10:58 pm EST

    Hello,

    Could you please try after using the standard dialog:

    Document.Print(GrapeCity.Viewer.Common.PrintingSettings.UseStandardDialog);
    
    

    Thanks,

    Mohit

  • Posted 17 March 2020, 10:50 pm EST

    Hello Mohit,

    thank you for your response! I have changed the call of the Print method from:

    sectionReport.Document.Print(true, true);

    to:

    sectionReport.Document.Print(PrintingSettings.UseStandardDialog | PrintingSettings.ShowPrintDialog | PrintingSettings.ShowPrintProgressDialog);

    I could see that the printer dialog is now opening much faster.

    Due to some conditions it is unfortunatelly not possible to test these changes on the PC of the user on which the error occurs, but we will take this change into the upcoming release of our application. It will be released soon! Then I will let the community know if this was the solution. :wink:

    Regards

    Mario

  • Posted 17 March 2020, 10:53 pm EST

    Hello Mario,

    Thanks for the information. We will wait for your confirmation on this issue.

    Thanks,

    Mohit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels