设置图像时参数无效 [英] Invalid parameter when setting an image
本文介绍了设置图像时参数无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
//下面的行抛出异常
this.myButton.BackgroundImage = global :: myNamespace.Properties.Resources .myImage;
异常:
code> ExceptionType:ArgumentException
消息:参数无效。
来源:System.Drawing
StackTrace:在System.Drawing.Image.get_Flags()
在System.Windows.Forms.ControlPaint.IsImageTransparent(Image backgroundImage)
在系统。 Windows.Forms.Control.set_BackgroundImageLayout(ImageLayout value)
资源存在,重置后工作正常。任何人都可以提供可能发生的任何见解?
解决方案
我建议您使用过程监视器来检查文件的实时活动以及哪些进程可能会锁定它。添加过滤器,其中Path是映像/资源文件的名称;这个应该很快就会显示出你背后的文件是否有任何东西。
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?
解决方案
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.
这篇关于设置图像时参数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文