PrintQueueWatch.NET component issues

Topics: Developer Forum
Coordinator
Sep 6, 2006 at 6:22 PM
Post any issues with the PrintQueueWatch.NET component here - even unrelated to the printer usage monitoring application itself.
Developer
Oct 28, 2006 at 12:16 AM
I have been playing with this component for a few weeks, I really love it, but there is one problem. The Dispose() method of the component throws an error that there is an invalid handle. Have you seen this?


I'll post the code I'm using here:

//Referenced PrintQueueWatcher
public class watchprinter
{
private PrinterMonitorComponent pPrinter = new PrinterMonitorComponent();

public bool Start()
{


pPrinter.MonitorJobAddedEvent = true;
pPrinter.MonitorJobDeletedEvent = false;
pPrinter.MonitorJobWrittenEvent = true;


pPrinter.JobAdded += new EventHandler(pPrinter_JobAdded);
pPrinter.JobWritten += new EventHandler(pPrinter_JobWritten);

return true;
}


public bool Stop()
{
pPrinter.Dispose();
}

private void pPrinter_JobAdded(Object sender, System.EventArgs e)
{

PrinterQueueWatch.PrintJobEventArgs pJob = (PrinterQueueWatch.PrintJobEventArgs)e;
OnJobEvent(PrinterQueueWatch.PrintJobEventArgs.PrintJobEventTypes.JobAddedEvent, pJob.PrintJob);

}

private void pPrinter_JobWritten(Object sender, System.EventArgs e)
{
PrinterQueueWatch.PrintJobEventArgs pJob = (PrinterQueueWatch.PrintJobEventArgs)e;
OnJobWrittenEvent(PrinterQueueWatch.PrintJobEventArgs.PrintJobEventTypes.JobAddedEvent, pJob.PrintJob);
}

private void OnJobWrittenEvent(PrinterQueueWatch.PrintJobEventArgs.PrintJobEventTypes EventType, PrinterQueueWatch.PrintJob job)
{
//Waiting for Spooled Job and do something once spooled.
}

private void OnJobEvent(PrinterQueueWatch.PrintJobEventArgs.PrintJobEventTypes EventType, PrinterQueueWatch.PrintJob job)
{

job.Paused = true;


}


}
Coordinator
Oct 31, 2006 at 8:11 AM
This discussion has been copied to Work Item 4953. You may wish to continue further discussion there.
Coordinator
Nov 2, 2006 at 7:52 AM
I have made changes in the Dispose() functionality but was not able to recreate the issue - can you check with the current code set...
Feb 15, 2007 at 3:20 PM
Hello,

I´ve installed the component on computer and built an application to monitor my printers.

The monitoring works fine but im having problems to get the number of pages and copies printed. The proprierty "TotalPages" of the job colletion, always return the same value as proprierty "PagesPrinted", and its even worse with Word and Excel: The value of proprierty "Copies" always return "1".

How can I do to get the exact number of pages and copies of each printed document ?

Thank you.
Developer
Mar 15, 2007 at 3:09 AM
I downloaded chageset 19883 with the comment "Added the strong name key files (*.snk) to source control and minor change to exclude invalid printers (i.e. Name is Nothing) from Server.Printers".
but when I try adding printer , there was an exception:

'===================
System.TypeInitializationException was unhandled
Message="The type initializer for 'PrinterQueueWatch.PrinterMonitorComponent' threw an exception."
Source="PrinterQueueWatch"
TypeName="PrinterQueueWatch.PrinterMonitorComponent"
StackTrace:
......
......
'===================
the exception occured
in PrinterQueueWatch Project/PrinterInformation.vb
at sub RefreshPrinterInformation(ByVal level As PrinterInfoLevels)
as following:
"
Private Sub RefreshPrinterInformation(ByVal level As PrinterInfoLevels)
If mhPrinter.Equals(IntPtr.Zero) Then
If PrinterMonitorComponent.ComponentTraceSwitch.TraceError Then
Trace.WriteLine("RefreshPrinterInformation failed: Handle is
invalid", Me.GetType.ToString)
End If
Exit Sub
End If
"
When I inserted a Try - Catch statement, the exception were threw, but the number of checkedboxs equals to the number of printers displayed with empy name!
Do you thing that occoured due to my try-catch Satatement? and what can I do to see all printers' name?

Jun 27, 2009 at 8:38 AM

Message: HandlingInstanceID: 059109dc-677e-48e3-8c8f-a00616f34e03
An exception of type 'System.ComponentModel.Win32Exception' occurred and was caught.
------------------------------------------------------------------------------------
06/27/2009 08:52:25
Type : System.ComponentModel.Win32Exception, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The handle is invalid
Source : PrinterQueueWatch
Help link :
NativeErrorCode : 6
ErrorCode : -2147467259
Data : System.Collections.ListDictionaryInternal
TargetSite : Void DecodePrinterChangeInformation()
Stack Trace :    at PrinterQueueWatch.PrinterChangeNotificationThread.DecodePrinterChangeInformation()
   at PrinterQueueWatch.PrinterChangeNotificationThread.StartThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

This exception gets thrown when I use PrinterQueueWatch.NET from my C# application. Can anyone help me out?

Jul 27, 2009 at 8:08 AM

Hi M,

 

I tried to make a small logger for logging color prints on Windows 2003 STD: no problem everything works just fine. I used the sample on your site as a basis, just logging extra fields Color, that's all.

Now the problem is that when i want to monitor on a Windows 2003 x64-system that my solution doesn't work anymore :( Can you help me out with this?

Here's the logfile:

PrinterQueueWatch.PrinterChangeNotificationThread: StartWatching created new thread: PrinterChangeNotificationThread:429936360
PrinterQueueWatch.PrinterChangeNotificationThread: StartThread() of printer handle :429936360
PrinterQueueWatch.PrinterNotifyOptions: New(True)
PrinterQueueWatch.PrinterChangeNotificationThread: StartThread() of printer handle :429936168
PrinterQueueWatch.PrinterNotifyOptions: New(True)
PrinterQueueWatch.PrinterNotifyOptionsType: New(True)
PrinterQueueWatch.PrinterNotifyOptionsType: New(True)
PrinterQueueWatch.PrinterNotifyOptionsType: SetupFields()
PrinterQueueWatch.PrinterNotifyOptionsType: SetupFields()
PrinterQueueWatch.PrinterChangeNotificationThread: StartWatch: FindFirstPrinterChangeNotification succeeded - handle: 672 for printer handle: 429936360
PrinterQueueWatch.PrinterChangeNotificationThread: StartWatch: FindFirstPrinterChangeNotification succeeded - handle: 668 for printer handle: 429936168
PrinterQueueWatch.PrinterChangeNotificationThread: DecodePrinterChangeInformation() for printer handle: 429936360
PrinterQueueWatch.PrinterChangeNotificationThread: FindNextPrinterChangeNotification did not return a pointer to PRINTER_NOTIFY_INFO - the change flag was:61696
PrinterQueueWatch.PrinterChangeNotificationThread: DecodePrinterChangeInformation() for printer handle: 429936168
PrinterQueueWatch.PrinterChangeNotificationThread: FindNextPrinterChangeNotification did not return a pointer to PRINTER_NOTIFY_INFO - the change flag was:61696

 

Feel free to contact me directly if you prefer. And thx to anyone helping me out with this :-)

Greetings from Belgium,

 

Thierry

Aug 4, 2009 at 9:37 AM

Dear bottent,

i have found some problem when use solution from this server.. i has try to debug, but i can't to solve it..

can i get the fresh solution from you ( management Console until monitor viewer) ? ( i'm using .net 2005 )

My email is  jeffry_untoro@app.co.id,

i really needed, Thanks a lot for your attention ..

Best Regards,

Jeffry untoro

Coordinator
Aug 4, 2009 at 9:53 AM

Hi

The PrintQueueWatch component does not work under 64bit windows at the moment, and unfortunately I don't have a 64 bit test rig to work on to fix it...

There is a discussion on the component's own CodePlex page that may yield a solution as other people are looking at the issue.