繁体   English   中英

无法创建抽象类或接口“ System.Drawing.Image”的实例

[英]Cannot create an instance of the abstract class or interface 'System.Drawing.Image'

Image img = new Image();
img.ImageUrl = "images/sample1.jpg?rnd=" + (new Random()).Next();  
    // added random for caching issue.
this.Controls.Add(img);

我得到的错误

无法创建抽象类或接口'System.Drawing.Image'的实例--->第1行

'System.Drawing.Image'不包含'ImageUrl'的定义,找不到扩展方法'ImageUrl'接受类型为'System.Drawing.Image'的第一个参数(您是否缺少using指令或程序集引用?)---> Line2

最佳重载方法匹配'System.Web.UI.ControlCollection.Add(System.Web.UI.Control)'有一些无效的参数---> Line3

错误10参数“ 1”:无法从“ System.Drawing.Image”转换为“ System.Web.UI.Control”

请帮助我解决错误。

看来您尝试使用错误的Image类。 完全合格,它应该像您期望的那样工作。

  System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
    img.ImageUrl = "images/sample1.jpg?rnd=" + (new Random()).Next();  // added random for caching issue.
    this.Controls.Add(img);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM