RPC_E_DISCONNECTED 在 InternetExplorer 自动化期间
RPC_E_DISCONNECTED during Automation of InternetExplorer
我正在尝试自动化 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/
您是否尝试使用 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");
}
输出:
参考:
我正在尝试自动化 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/
您是否尝试使用 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");
}
输出:
参考: