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?
User contributions licensed under CC BY-SA 3.0