繁体   English   中英

c# 指定的转换在分配 mshtml.HTMLDocument.frames 时无效

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

我正在开发 IE BHO,在访问 html 文档中的框架时出现此错误

这是代码。

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
   }
}

这里有什么问题?

好的,我通过在函数调用时设置[STAThread]解决了这个问题

暂无
暂无

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

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