none
Using SHDocVw.InternetExplorer() BUT having problems with events and other properties RRS feed

  • Question

  • Hi Guys.

    I'm starting a browser window using the above method. My ultimate goal is to get to the Document property but all is failing at the moment.

    If I wire up the DocumentComplete event or any other even for that matter, leaving just the default throw exception implementation, nothing happens. These events never fire. No exception thrown.

    If I try to access the Document property after a timeout (making sure it has loaded), then I get an error :

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

     

    Can anyone please advise. Using VS2010. Windows 7 64bit.

     

    I see examples all over doing the above yet this won't work.

    _internetExplorer = new SHDocVw.InternetExplorer();
    _internetExplorer.Visible = this._hideInternetExplorer;
    _internetExplorer.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(_internetExplorer_DocumentComplete);
    _internetExplorer.Navigate(this._address);
    Thread.Sleep(10000);
    mshtml.IHTMLDocument3 doc = _internetExplorer.Document;
    

     

    Tuesday, November 16, 2010 9:41 PM

Answers

  • as all other STA COM servers, IE requires you to pump messages.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Tuesday, November 16, 2010 10:16 PM
  • Hi Tezler,

    Welcome to MSDN Forums!

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

    This problem can occur when a single-threaded apartment (STA) does not properly process messages in one or more COM applications. An STA thread should always check the message queue and dispatch messages.

     

    I tested the codes from your post, and this error message was given to me after I close the website, otherwise the code worked well in my side.

     

    And I think is when you close the website opened by your code, the com server will be disconnected with its client.

     

    If there’s anything unclear, please feel free to let us know.

    Have a nice day!

    Mike

     

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com

    -------------------------------------------------------------------

    If(helpful) -> Mark

    *****************************************************

    Welcome to the new world! [All-In-One Code Framework]

    Monday, November 22, 2010 8:07 AM
    Moderator

All replies

  • as all other STA COM servers, IE requires you to pump messages.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Tuesday, November 16, 2010 10:16 PM
  • Appreciate the reply but not sure what that means in relation to the question?

    As it turns out, seems like some strange scope issue was to blame! The above logic was wrapped up into a class method, the class was instantiated in the OnClick even of a button and the method then called. If I move the above logic straight into the OnClick of a button then it all works fine!

    What did you mean by your reply?

    Of another note. The reason I am trying to do this is to wrap a VPN connection. We visit an address and login from there. ActiveX components (f5) are used in the browser. It's annoying that the vpn connection is closed though when IE closes. As a result I accidently terminate the connection all the time which sees me having to login all the time. Idea was to launch IE from a windows app, populate fields and then login. It all nearly works but something is a now a miss with the way the browser launches. I have no idea but when it loads using the above code, it appears as though the activex control is missing or cant load which results in a "please install activex". IT IS installed though because manually opening IE and visiting the page loads the activex control fine.

    Do you know what the above could be? Does IE open differently when using the above code? Not enough trust or something?

    Saturday, November 20, 2010 1:47 PM
  • Thread.Sleep blocks IE's events. The documentcompleted event is not being processed (that is, if the navigation is not sent to another IE process due to integrity level change) since you use Thread.Sleep. You should wait using a message pump. But since you are on Windows 7, the cross-process message is blocked by UIPI anyways.

    The integrity level of the IE instance created by your code is decided by your app's integrity level, most likely medium integrity level. The integrity level of the web page is decided by the internet zone of the url and the protected mode setting of zone, by default an internet zone url goes to the low integrity level process, and your navigation results the medium integrity level IE process you created to send the navigation request to a low integrity level IE process that you have no control over (blocked by UIPI).

    I suggest you to write a BHO to break UIPI from inside the IE process instead.

     



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Saturday, November 20, 2010 3:43 PM
  • Hi Tezler,

    Welcome to MSDN Forums!

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

    This problem can occur when a single-threaded apartment (STA) does not properly process messages in one or more COM applications. An STA thread should always check the message queue and dispatch messages.

     

    I tested the codes from your post, and this error message was given to me after I close the website, otherwise the code worked well in my side.

     

    And I think is when you close the website opened by your code, the com server will be disconnected with its client.

     

    If there’s anything unclear, please feel free to let us know.

    Have a nice day!

    Mike

     

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com

    -------------------------------------------------------------------

    If(helpful) -> Mark

    *****************************************************

    Welcome to the new world! [All-In-One Code Framework]

    Monday, November 22, 2010 8:07 AM
    Moderator
  •  Hi Tezler,

     

    Have you solved this problem? And have the information above helpful for you to solve this problem?

     

    If there's anything unclear, please feel free to let me know.

     

    Have a nice day!

    Mike

    *****************************************************

    [All-In-One Code Framework]

    Sample world! You will get more from this world!

    Welcome to the new world!

    Wednesday, November 24, 2010 4:56 AM
    Moderator