3
我有铸造mshtml.HTMLDocumentClass
一个问题mshtml.IMarkupServices
无法施展“mshtml.HTMLDocumentClass”到“mshtml.IMarkupServices”
IHTMLDocument2 doc = new HTMLDocumentClass();
doc.write(new object[] { item.HTMLBody });
IHTMLTxtRange range = ((IHTMLBodyElement)doc.body).createTextRange();
IHTMLTxtRange baseRange = ((IHTMLBodyElement)doc.body).createTextRange();
var markupServices = (IMarkupServices)doc; // <--- exception is thrown here
相同的代码工作在一种情况下但在另一个抛出异常。 这些调用是相同的,但在代码的不同位置不能以相同的方式工作。
小心使用线程,如果你运行的是没有创建文档线程代码这个转换可能会失败。 –
@HansPassant是的,它在使用线程的部分不起作用。你能提出任何解决方案吗? – Andriy
@HansPassant感谢提示它是有帮助的。 – Andriy