I want to call a specific printer to print in my WPF application. I have three printer Suppose Printer1 for Bar bill Print Printer2 for Kitchen bill Print Printer3 for Guest bill Print printers name already saved in database, while printing I get a printer name from DB and want to print from specific printer, not defaul printer Here is my code
var v = new PrinterDAL().GetPrinterSettings();
try
{
System.Threading.Thread thread = new System.Threading.Thread(new
System.Threading.ThreadStart(
delegate()
{
gridPrint.Dispatcher.Invoke(DispatcherPriority.Normal,
new Action(
delegate()
{
PrintDialog printDialog = new PrintDialog();
printDialog.PrintQueue = new PrintQueue(
new PrintServer(@"\\" + v.BarPrinter), "");
printDialog.PrintVisual(gridPrint, "");
this.Close();
}
));
}
));
thread.Start();
}
catch (Exception ex)
{
Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, "", MessageBoxButton.OK,
MessageBoxImage.Error);
}
I get an exception from this code
"An exception occurred while creating the PrintServer object. Win32 error: The printer name is invalid."
v.BarPrintercontain?