Sep 22, 2015 at 6:00 PM

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 PrintQueueWatch.PrinterChangeNotificationThread.StartThread()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
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)
at System.Threading.ThreadHelper.ThreadStart()

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?

Please advice,

Thank you.
Sep 23, 2015 at 5: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 8:35 AM
Edited Sep 28, 2015 at 4: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
Source: PrintQueueWatch
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.

Thanks again.

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?