使用winforms时COM互操作错误0x80010108(RPC_E_DISCONNECTED)

时间:2017-10-24 13:25:36

标签: c# winforms internet-explorer

我正在使用WinForm应用程序打开一个高度和宽度的新IE浏览器,我得到以下异常:

  

System.Runtime.InteropServices.COMException(0x80010108):调用的对象已与其客户端断开连接。 (来自HRESULT的异常:0x80010108(RPC_E_DISCONNECTED))

它似乎引用的代码:

[DllImport("User32.dll")]
public static extern Int32 SetForegroundWindow(int hWnd);

dynamic ie = Activator.CreateInstance(Type.GetTypeFromProgID("InternetExplorer.Application");

string URL = "https://www.google.com/";
ie.ToolBar = 0;
ie.StatusBar = false;
ie.MenuBar = false;
ie.Width = 800;
ie.Height = 550;
ie.Visible = true;
ie.Resizable = false;
ie.AddressBar = false;
ie.Visible = true;
ie.Top = 230;
ie.Left = 300;
ie.Navigate(URL);
SetForegroundWindow(ie.Hwnd)

有什么想法吗?

0 个答案:

没有答案