c# specified cast is not valid while assigning mshtml.HTMLDocument.frames

℡╲_俬逩灬. 提交于 2019-12-11 03:34:49

问题


I'm developing an IE BHO, While accessing frames in a html document i'm getting this error

Here is the code.

foreach (SHDocVw.InternetExplorer objExplorer in objShellWins)
{
   if (objExplorer.Document is HTMLDocument)
   {
      objDocument = (mshtml.HTMLDocument)objExplorer.Document;
      mshtml.HTMLDocument doc = (mshtml.HTMLDocument)objExplorer.Document;
      mshtml.FramesCollection frames = (mshtml.FramesCollection)doc.frames;  //Exception at this line
   }
}

what is the issue here ?


回答1:


OK people i got it solved by setting [STAThread] at function calling



来源:https://stackoverflow.com/questions/19180191/c-sharp-specified-cast-is-not-valid-while-assigning-mshtml-htmldocument-frames

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!