I have some code that has been working for me for several months, but today, I am getting casting errors?
I am using the mshtml library to click an adjust input image:
mshtml.IHTMLElementCollection objCollection = (mshtml.IHTMLElementCollection)objDocument.getElementsByName("submit");
for (int i = 0; i < objCollection.length; i++)
{
mshtml.IHTMLElement objElement = (mshtml.IHTMLElement)objCollection.item(i, 0);
if (objElement.getAttribute("alt") == "adjust")
{
// This line below gives me the error.
mshtml.htmlInputImage objSubmit = (mshtml.htmlInputImage)objElement;
objSubmit.click();
bOK = true;
}
}
At the // line above, I get the following message:
Unable to cast object of type 'mshtml.HTMLInputElementClass' to type 'mshtml.htmlInputImage'.
This used to work and this part of the code has not changed. Does anyone know what I might be doing wrong and why should this just start to not work? I use this type of structure in other places and all is working...