COM Interop error 0x80010108 (RPC_E_DISCONNECTED) when using winforms

0

I am using WinForm application to open a new IE browser with height and width and I got below exception:

System.Runtime.InteropServices.COMException (0x80010108): The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))

And the code it seems to be referencing:

[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)

Any ideas please?

c#
winforms
internet-explorer
asked on Stack Overflow Oct 24, 2017 by sangeetha • edited Oct 24, 2017 by Equalsk

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0