Getting InvalidPrinterName exception setting printer name:
rptStatement.PrintOptions.PrinterName = UNCPrinterName;
CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.ModifyPrinterName(String newVal)
at CrystalDecisions.CrystalReports.Engine.PrintOptions.set_PrinterName(String value)
Using Crystal Reports with Visual Studio 2008 in a Winforms application.
Running under Windows Terminal Server under high priveleged (administrator) account. If the printer is set as the default printer it works. The printer is 'valid' - the following logic is run to determine if a printer needs to be set before attempting to print:
void checkPrinter(string printerName)
{
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
ps.PrinterName = printerName;
//if it's NOT visible as a valid printer then select
if (!ps.IsValid)
{
PrintDialog pd = new PrintDialog();
pd.UseEXDialog = true;
pd.ShowNetwork = true;
if (pd.ShowDialog()== DialogResult.OK)
{
}
printer = pd.PrinterSettings.PrinterName;
}
}
Various posts such as http://scn.sap.com/message/10211706#10211706 and http://social.msdn.microsoft.com/Forums/eu/vscrystalreports/thread/b3e39e29-0899-4778-975f-f38c927dfe9e refer to directly using PrintOutputController and PrintReportOptions , which should be exposed through the CR report ReportClientDocument property - except I am unable to get any additional property/methods from this. Is it not available in VS 2008 CR?
I can only assume I need additional references added?
Any help is appreciated and thanks ahead of time.
rpt = ProvideRpt();
CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();
rasPROpts.PrinterName = txt_CRPrinter.Text;
rpt.ReportClientDocument.PrintOutputController.PrintReport(rasPROpts);