【问题标题】:RPC_E_DISCONNECTED during Automation of InternetExplorerInternetExplorer 自动化期间的 RPC_E_DISCONNECTED
【发布时间】:2019-11-05 10:05:03
【问题描述】:

我正在尝试自动化 Internet Explorer。 有时,导航到 URL 时,我会看到以下错误:RPC_E_DISCONNECTED

        AutoResetEvent _isStopping = new AutoResetEvent(false);
        IE = new SHDocVw.InternetExplorer();
        try
        {
            object URL = target;
            IE.Visible = false;
            IE.Navigate2(ref URL);
            int hwnd = IE.HWND;

问题发生在 Navigate2 上。

我确实找到了可能是我看到的问题的信息,但我不确定解决方案如何转换为 c#。
https://blogs.msdn.microsoft.com/ieinternals/2011/08/03/default-integrity-level-and-automation/

【问题讨论】:

  • 仅供参考,根据tagging help page“你应该在标题中使用标签的唯一时间是它们与标题的对话语气有机。”

标签: c# internet-explorer


【解决方案1】:

您是否尝试使用 IE.Navigate 而不是 IE.Navigate2?

我在我这边测试过,它工作正常。

 private void button1_Click(object sender, EventArgs e)
        {
            SHDocVw.InternetExplorer ie = null;
            ie = new SHDocVw.InternetExplorer();
            ie.Navigate("www.microsoft.com", Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            ie.Visible = true;
        }

如果您想使用 Internet Explorer 媒体创建对象,那么您可以参考下面的示例。

private void button1_Click(object sender, EventArgs e)
        {           
                    SHDocVw.InternetExplorerMedium IE = new SHDocVw.InternetExplorerMedium();
                    IE.Visible = true;
                    IE.Navigate("www.microsoft.com");    
        }

输出:

参考:

(1)Automate Internet Explorer using C#.Net

(2)Using C# SHDocVw.InternetExplorer for form submitting

【讨论】:

  • Navigate 和 Navigate2 有什么区别。我认为 Navigate2 是一种更新(并且改进了?)的方法?
  • 参数和功能有些不同。您可以参考此线程以获取有关差异的更多信息。 stackoverflow.com/questions/4538097/…我建议它用于测试目的,以验证使用它是否有任何不同。
猜你喜欢
  • 2012-07-16
  • 1970-01-01
  • 2015-09-26
  • 1970-01-01
  • 2016-04-04
  • 2013-01-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多