5

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?

3
  • 2
    Possibly the image file got locked by something? Virus scanner pops into mind... Commented Aug 3, 2012 at 12:52
  • Yip, agreed... disable anti-virus Commented Aug 3, 2012 at 12:59
  • @CodingGorilla I'll try that if I can replicate. Commented Aug 3, 2012 at 13:05

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Yes, this is a 6 year old post! Ran into the same error today, and it took me far longer to fix than it should have. I was actually disposing my image control on startup, so I obviously couldn't adjust its background image on run-time. Might as well double check for that if you're here.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.