ReportViewer Print Error To Non-Default Printer
Hi, I am using the ReportViewer control on a Windows form. After a report is rendered succesfully in the control, if I click on the Print button in the ReportViewer toolbar and print to a printer that is NOT the user's default printer, I receive the error "The handle is invalid." It works fine anytime you print to the default printer. I'm wondering if someone can tell me if there is a fix for this in any service packs, new releases, etc. I am currently using SQL Server 2008 and Visual Studio 2008. This same issue was mentioned at the bottom of the following thread, but it doesn't appear that anyone ever responded that it was ever fixed. You would think this issue would be fixed after 4 years now. http://social.msdn.microsoft.com/Forums/en-US/vsreportcontrols/thread/42e80277-b2c6-4a70-9ba2-e7b039d6ec26/ Thanks, ~Corey
June 8th, 2010 10:04pm

Hi Corey, If I understand correctly, you encountered the following error: System.ComponentModel.Win32Exception: The handle is invalid at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) This is a Win32 exception, and it happens in .NET object 'StandardPrintController' in method 'OnStartPrint'. Generally, it may be caused by a printer driver. So, could you please to re-install the driver of the printers or udpate the driver to date to check if the issue is solved. Also, please make sure the ReportViewer control, the Reporting Services and the Visual Studio is updated to date. I met a print fail issue that is caused by network printer with larger latency, and the hotfix is provided recently. If you have any more questions, please feel free to ask. Thanks, Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
June 10th, 2010 12:28pm

Hi Corey, If I understand correctly, you encountered the following error: System.ComponentModel.Win32Exception: The handle is invalid at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) This is a Win32 exception, and it happens in .NET object 'StandardPrintController' in method 'OnStartPrint'. Generally, it may be caused by a printer driver. So, could you please to re-install the driver of the printers or udpate the driver to date to check if the issue is solved. Also, please make sure the ReportViewer control, the Reporting Services and the Visual Studio is updated to date. I met a print fail issue that is caused by network printer with larger latency, and the hotfix is provided recently. If you have any more questions, please feel free to ask. Thanks, Jin ChenJin Chen - MSFT
June 10th, 2010 12:28pm

Hi Jin, Thanks for your reply. Yes that is the error I am getting and it happens when I call the PrintDialog() method of the ReportViewer control when the user clicks Print after selecting a printer that is NOT their default printer. This appears to happen with any printers. I re-installed the drivers of the two printers I am testing with and I still get the same problem. I can print reports to both printers successfully if the printer I choose is my default printer. I am using SQL Server 2008 and Visual Studio 2008. You told me to make sure I am using all the latest software for ReportViewer control, SSRS, and VS, so are you saying there is a fix for this in either Visual Studio 2010 or SQL Server 2008 R2? I downloaded the Microsoft ReportViewer 2010 redistributable and tried to print a report to a non default printer and still receive the same error. Have you tried these steps yourself and it works for you? Thanks, ~Corey
Free Windows Admin Tool Kit Click here and download it now
June 10th, 2010 3:21pm

hey did you ever get this fixed?
October 28th, 2010 1:44pm

Got it! Add the below into the PrintingBegin event. The Print dialog on the reportviewer control doesn't pass the values properly, but setting them manually seems to work. Private Sub ReportViewer1_PrintingBegin(sender As Object, e As Microsoft.Reporting.WinForms.ReportPrintEventArgs) Handles ReportViewer1.PrintingBegin ReportViewer1.PrinterSettings.PrinterName = e.PrinterSettings.PrinterName ReportViewer1.PrinterSettings.FromPage = e.PrinterSettings.FromPage ReportViewer1.PrinterSettings.ToPage = e.PrinterSettings.ToPage End SubDan
Free Windows Admin Tool Kit Click here and download it now
December 9th, 2010 7:22am

Daniel, you're a godsend... I've been searching for a solution high and low, as the exceptions were really mindboggling (from OutOfMemory to application crashes). Thanks!
May 20th, 2011 9:09am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics