如何在 VB.NET 中使用 MSHTML?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/550479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I use MSHTML in VB.NET?
提问by Jim Counts
In the answer to question #56107, Erlend provided this sample c# code:
在问题 # 56107的答案中,Erlend 提供了以下示例 c# 代码:
using mshtml;
...
object[] oPageText = { html };
HTMLDocument doc = new HTMLDocumentClass();
IHTMLDocument2 doc2 = (IHTMLDocument2)doc;
doc2.write(oPageText);
I'd like to use mshtml in VB.NET, but the IDE doesn't recognize this:
我想在 VB.NET 中使用 mshtml,但 IDE 无法识别:
Imports mshtml
What additional steps do I need to take to use MSHTML in VB.NET?
在 VB.NET 中使用 MSHTML 需要采取哪些额外步骤?
回答by Jim Counts
Found an answer to my own question:
找到了我自己问题的答案:
If you are interested, here is the solution based on VB.NET which you can use with ASP.NET(.aspx.vb). Make sure you add reference to Microsoft.mshtml from the .NET objects collection and "Imports System.Runtime.InteropServices"
如果您有兴趣,这里是基于 VB.NET 的解决方案,您可以将其与 ASP.NET(.aspx.vb) 一起使用。确保从 .NET 对象集合和“导入 System.Runtime.InteropServices”添加对 Microsoft.mshtml 的引用
With this clue, I found this by opening the "Add Reference" dialog, and looking under the COM tab, not the .NET tab. It's Component Name was Microsoft HTML Object Library.
有了这个线索,我通过打开“添加引用”对话框找到了这个,并在 COM 选项卡下查看,而不是 .NET 选项卡。它的组件名称是 Microsoft HTML Object Library。
回答by H Ahmad
Imports System.Runtime.InteropServices and
导入 System.Runtime.InteropServices 和
"With this clue, I found this by opening the "Add Reference" dialog(project==>Add Reference), and looking under the COM tab, not the .NET tab. It's Component Name was Microsoft HTML Object Library."
“有了这个线索,我通过打开“添加引用”对话框(项目==>添加引用)找到了这个,然后在 COM 选项卡下查看,而不是 .NET 选项卡。它的组件名称是 Microsoft HTML 对象库。”
it work 100%
它工作 100%