c# specified cast is not valid while assigning msh

2019-07-23 07:19发布

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条回答
2楼-- · 2019-07-23 07:58

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

查看更多
登录 后发表回答