'PrinterSettings object not correctly initialized with disconnected vpn connection
My coworker implemented a function for setting the index of the default printer.
private void SetPrinterToDefault()
{
PrinterSettings printerSettings = new PrinterSettings();
int result = 0;
for (int i = 0; i < System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count; i++)
{
if (System.Drawing.Printing.PrinterSettings.InstalledPrinters[i] == printerSettings.PrinterName)
{
result = i;
}
}
PrinterIndex = result;
PrinterSettings.DefaultPageSettings.Landscape = true;
}
For him this function works without problems. For me I get an Exception as soon as the code tries to access a property of the PrinterSettings object.
Exception: hr_error at location 0x000000CFE0976810.
When i inspect the object it shows me the following problem
CanDuplex = Cannot evaluate expression because a native frame is on the top of the call stack.
(German original) CanDuplex = Ausdruck kann nicht evaluiert werden, da sich ein nativer Frame oben auf dem Aufrufstapel befindet.
for all Properties.
What really sucks me up: Every time my PC is connected to our corporate Network via VPN, the PrinterSettings object works as expected.
Any suggestions for a workaround or a solution for fixing the issue?
Solution 1:[1]
The solution for me was uninstalling my local WLAN Printer (HP Office Jet 8010). I have no idea why this is working. Eventually the contructor call of PrinterSettings tries to contact the printer, which is in standby and answers to slow.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | niyou |
