我将VB.Net
应用程序转移到C#
并在我构建它时。出现了这个错误-
“mshtml.IHTMLImgElement”不包含“getattribute”的定义,并且找不到接受“mshtml.IHTMLImgElement”类型的第一个参数的扩展方法“getattribute”(您是否缺少 using 指令或程序集引用?)
那么我该如何替换这个getattribute
调用呢?
这是代码
private void captcha()
{
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2) WebBrowser1.Document.DomDocument;
mshtml.IHTMLControlRange imgrange = (mshtml.IHTMLControlRange) (((mshtml.HTMLBody) doc.body).createControlRange());
foreach (mshtml.IHTMLImgElement img in doc.images)
{
if (img.getattribute("src").ToString().Contains("urltoimg"))
{
imgrange.add((mshtml.IHTMLControlElement) img);
imgrange.execCommand("copy", false, null);
PictureBox1.Image = (System.Drawing.Image) (Clipboard.GetDataObject().GetData(DataFormats.Bitmap));
break;
}
}
}