Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Parameter is not valid" Thrown from System.Drawing.Graphics.GetHdc()-- Only on Some Machines

Tags:

c#

winforms

I encountered this error "Parameter is not valid", and it is thrown from

System.Drawing.Graphics.GetHdc()

The weird thing is that it is only thrown this error on one machine, but not on other machines.

Sorry for being vague, any idea you have that can solve this problem?

like image 981
Graviton Avatar asked Sep 29 '10 02:09

Graviton


1 Answers

See if this applies to you? Parameter is not valid

You'll find that your problem is caused by a GDI leak. Open up TaskManager and if the Processes Tab does not have a GDI objects column then add it via the View menu. You should then see that the GDI Objects keep growing until eventually your app falls over. Once you add the DeleteDC() call you should see that the GDI Objects stays fairly constant.

like image 141
Aaron Pattillo Avatar answered Nov 12 '22 21:11

Aaron Pattillo