Page 1 of 1

PrintDialogFit throw excption

Posted: Wed Jun 20, 2012 1:28 pm
by kenfly51
currently i'm working with printing function and i used function PrintDialogFit(IWin32Window) for printing, but it's unstable, some pc can print well, but some, and it throw exception:

Code: Select all

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Drawing.Printing.PrinterSettings.GetModeField(ModeField field, Int16 defaultValue, IntPtr modeHandle)
   at System.Drawing.Printing.PrinterSettings.get_Collate()
   at System.Windows.Forms.PrintDialog.GetFlags()
   at System.Windows.Forms.PrintDialog.ShowPrintDialog(IntPtr hwndOwner, PRINTDLGEX data)
   at System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
   at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
   at gdpicture_?.gdpicture_?(IWin32Window A_0, Boolean A_1, Single A_2, Single A_3, Single A_4, Single A_5, Boolean A_6)
   at GdPicture.GdViewer.PrintDialogFit(IWin32Window owner)
   at EDM.UI.ViewModels.DocumentViewerViewModel.PrintAttachment()
i can not figure out what happened, please help me, thanks

Re: PrintDialogFit throw excption

Posted: Tue Jun 26, 2012 12:51 pm
by Loïc
Hello,

I think you have a problem with the printer driver. Basically the WinAPI fails to shows the generic printing dialog box.

What I can suggest you is to catch & handle the raised exception by wrapping your call between try/catch/finally block.

The next release will return a proper GdPictureStatus instead of raising such exception.

Kind regards,

Loïc