2012-08-03 114 views
4

我在许多计算机上运行.NET 2.0程序。在一个我有重复出现此错误,直到我重置应用程序。设置图像时参数无效

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

例外:

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) 

的资源存在,它工作正常,一旦复位。任何人都可以提供任何见解,可能会发生?

+2

图像文件可能被某些东西锁定了?病毒扫描器突然出现... – CodingGorilla 2012-08-03 12:52:15

+0

叶,同意...禁用防病毒 – Fox 2012-08-03 12:59:49

+0

@CodingGorilla我会尝试,如果我可以复制。 – 2012-08-03 13:05:45

回答

1

我建议您使用Process Monitor来检查文件的实时活动,以及哪些进程可能会锁定它。添加一个过滤器,其中路径是图像/资源文件的名称;这应该很快显示是否有任何东西在后面的文件周围。