Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid parameter when setting an image

I'm running a .NET 2.0 program on many computers. On one I had this error occurring repeatedly until I reset the application.

 //line below was throwing the exception
 this.myButton.BackgroundImage = global::myNamespace.Properties.Resources.myImage;

Exception:

 ExceptionType: ArgumentException
 Message: Parameter is not valid.
 Source: System.Drawing
 StackTrace:    at System.Drawing.Image.get_Flags()
     at System.Windows.Forms.ControlPaint.IsImageTransparent(Image backgroundImage)
      at System.Windows.Forms.Control.set_BackgroundImageLayout(ImageLayout value)

The resource exists and it works fine once reset. Can anyone provide any insight as to might be happening?

like image 814
probably at the beach Avatar asked Nov 14 '22 01:11

probably at the beach


1 Answers

I suggest you use Process Monitor to examine real-time activity on the file, and which processes might be locking it. Add a Filter where the Path is the name of the image/resource file; this should quickly show if anything is monkeying around with the file behind your back.

like image 157
Polyfun Avatar answered Dec 16 '22 09:12

Polyfun