Print Queue Exception - How Do I Catch It?

Should see like a relatively obvious one, but I'm unable to actually state that I want to catch this particular type of exception.  Debugging shows that it is of type PrintQueueException, but it never appears in intellisense.  Googling has shown a couple of similar problems but hasn't given me an indication of a solution, and due to standards I can't just catch type Exception.

Does anybody know how I can handle this issue?
LVL 15
Who is Participating?
angus_young_acdcConnect With a Mentor Author Commented:
Anybody able to help solve this?
Rahul Goel ITILSenior Consultant - DeloitteCommented:

I hope this could help you
System.Management.ObjectQuery oq = new System.Management.ObjectQuery
"SELECT * FROM Win32_PrintJob");
ManagementObjectSearcher query1 = new ManagementObjectSearcher(oq);
ManagementObjectCollection queryCollection1 = query1.Get();
foreach( ManagementObject mo in queryCollection1 )
Console.WriteLine("Printer Driver : " + mo["DriverName"].ToString());
Console.WriteLine("Document Name : " + mo["Document"].ToString());
Console.WriteLine("Document Owner : " + mo["Owner"].ToString());

Open in new window

angus_young_acdcAuthor Commented:
Hi mate,

Thanks for the code but I'm already returning the printer information that I need, I just need to know how to catch the PrintQueueException as it's unavailable in intellisense.
Rahul Goel ITILConnect With a Mentor Senior Consultant - DeloitteCommented:
you can not trap the exception using PrintQueueException class, you can get this class under System.Printing

refer to the following link:
angus_young_acdcAuthor Commented:
And how do I do that?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.