Im getting this error on my website
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.
I tried implementing some sample code: i found in the documentation here is the code, I get the above error when I try it off my webserver, I understand it can anyone help me with this.
here is my code.
the main change I did was I changed PrintDialog()
to Windows.Forms.PrintDialog()
because I have nothing that defines PrintDialog()
, ( perhaps here lies the problem)
Dim printDlg As Windows.Forms.PrintDialog = New Windows.Forms.PrintDialog()
' Initialize the Print Dialog with the number of pages in he document.
printDlg.AllowSomePages = True
printDlg.PrinterSettings.MinimumPage = 1
printDlg.PrinterSettings.MaximumPage = docWord.PageCount
printDlg.PrinterSettings.FromPage = 1
printDlg.PrinterSettings.ToPage = docWord.PageCount
'Dim owner As Windows.Forms.IWin32Window
If (Not printDlg.ShowDialog().Equals(Windows.Forms.DialogResult.OK)) Then
Return
End If
Dim awPrintDoc As AsposeWordsPrintDocument = New AsposeWordsPrintDocument(docWord)
awPrintDoc.PrinterSettings = printDlg.PrinterSettings
Dim previewDlg As Windows.Forms.PrintPreviewDialog = New Windows.Forms.PrintPreviewDialog()
' Pass the Aspose.Words' print document to the Print Preview dialog.
previewDlg.Document = awPrintDoc
' Specify additional parameters of the Print Preview dialog.
previewDlg.ShowInTaskbar = True
previewDlg.MinimizeBox = True
previewDlg.PrintPreviewControl.Zoom = 1
previewDlg.Document.DocumentName = docWord.Document.ToString()
'previewDlg.WindowState = FormWindowState.Maximized
previewDlg.WindowState = Windows.Forms.FormWindowState.Maximized
' Show appropriately configured Print Preview dialog.
previewDlg.ShowDialog()