-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
- HP Community
- Printers
- LaserJet Printing
- Printing with HP laserJet 10xx in .Net

Create an account on the HP Community to personalize your profile and ask a question
01-02-2020 01:51 AM
I am having a problem with with printing from .Net 2.0 on HP LaserJet 10xx printers.
Occasionally (sometimes once a month, sometimes once a day) printer gets 'blocked' in such a manner that it can not print anything from .net 2.0.
When printDocument.print method is invoked, it throws InvalidPrinterException, even if printer has just been selected from printDialog. Printer is online and working (everything else can be printed on it), only printing that goes through .net is blocked.
I have discovered that problem is in the following registry key:
HKEY_CURRENT_USER\Printers\DevModePerUser
If this key exists, PrintDocument.PrinterSettings.IsValid reports 'false'. The moment this key is erased PrintDocument.PrinterSettings.IsValid is 'true' and printer is working. Right now I am solving this the following way: If printer is "HP" and PrinterSettings is 'false' then check if registry key exists, erase the key and then do the printing. Now, I am aware this is lame, but so far I haven't been able to discover why this happens. I emphasize that this only happens with HP LaserJet 10xx printers. Printing from .NET is completely blocked until this registry key exists.
Has anyone seen such error and if yes, what is the solution?
01-02-2020 06:53 AM
Interesting observations, thanks for sharing!
This sounds like a .net and Windows issue more than an HP printer issue. The printer will print as long as the print commands are sent. However, .Net is checking registry values to determine if a print job is available to send to the printer or not. This cuts the printer out of the decision making process when .net is involved.
You may have better luck asking about this issue on Microsoft forums or one of the developer subs on Reddit. Most will recommend that you update your .net to a newer version as the first troubleshooting step.
Otherwise I would say that your programmatic work around is a good idea. You correctly isolated the problem down to a few variables. Someone would need to test your code against a current printer model and driver to see if it is still an issue with newer .net and HP drivers/software.
Experts are not HP Employees. Experts are advanced users, administrators, technicians, engineers or business partners who volunteer their time to answer community questions.
Please mark anything that is helpful with a Kudo.
When you are done troubleshooting, please mark one of the responses as the Solution.
This feedback enhances the community by helping future readers choose between multiple similar responses.