I get a strange exception from the following code:
var printDialog = new PrintDialog();
printDialog.ShowDialog();
var printDocument = new PrintDocument { DefaultPageSettings = { Landscape = true, PrinterSettings = new PrinterSettings { PrinterName = printDialog.PrintQueue.Name } } };
var updateResult = new UpdateResult<Image>(UpdateType.Print) { Success = true };
foreach (string location in fileLocation)
{
try
{
_printImage = Image.FromFile(location);
printDocument.PrintPage += PrintRequest;
}
catch (Exception exception)
{
}
}
printDocument.Print();
The final line throws a Win32Exception with the “descriptor invalid” detail, according to the msdn documentation, the only exception that should be thrown is the printer was not found. The exception, apparently, should be some kind of driver exception / non framework.
When I select my printer (Lexmark T640, setting to print directly to the printer port), the code prints fine, but when I select either of the other two printers that I have access to (the other T640 or dell color), the code doesn’t work, Two other printers are configured to print through our central print server, but I didn’t think it should matter. Can anyone give me any directions?
: printDialog.PrintQueue.Fullname . InvalidPrinterException , , , , , .