I am getting the following error on a windows xp machine Event Log:
Event Type: Error
Event Source: .NET Runtime
Event Category: None
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ComponentModel.Win32Exception
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
The code runs without problem on other windows xp machines. I don't have direct access on the specific machine but it should have similar specs (hardware and software).
If there are not any printers installed on the specific machine, could this be the source of the error?
Sep 23, 2015 at 4:30 PM
If there are no printers at all installed that might cause a problem - or if the logged on user does not have rights to see/enumerate the printers?
Can you turn on tracing and see what the PrinterName is set to (and if it throws up any other information)?
Sep 28, 2015 at 7:35 AM
Edited Sep 28, 2015 at 3:51 PM
Hello thank you very match for your reply.
It seems like there are some deprecated printers on the machine (renamed, removed etc.). The received error is:
Error: The printer name is invalid
Stack Trace: at PrintQueueWatch.PrinterInformation..ctor(String DeviceName, PrinterAccessRights DesiredAccess, Boolean GetSecurityInfo, Boolean GetJobs)
at PrintQueueWatch.PrinterMonitorComponent.AddPrinter(String DeviceName)
We will try to resolve the valid printers (check if a printer is valid via the System.Drawing.Printing.PrinterSettings.isValid property) before sending them to the AddPrinter method.
As an update, i tried to reproduce the error by renaming a shared domain printer and then print from a client in the domain but this did not throw any exceptions. I also added a dummy printer on that client (Add Printer-->local printer-->Select LPT2 port-->Select
Random Manufacturer and Device and install the printer) but this did not throw any exceptions either. All these printers are resolved as valid via the System.Drawing.Printing.PrinterSettings.isValid property.
Could this mean that this is an access rights issue? If so is there an alternative i can apply to the AddPrinter sub in order to bypass this behavior?