5

In certain 2008 R2 environments and not others, I'm getting a COMExceptions when utilizing a System.Windows.Forms.WebBrowser control. Whether specifying contents via the DocumentText property or invoking the Navigate method with a URL parameter, I get the same exception:

COMException - Error HRESULT E_FAIL has been returned from a call to a COM component.

at System.Windows.Forms.UnsafeNativeMethods.IWebBrowser2.Refresh()

I've found that setting the ScrollBarsEnabled property on the WebBrowser before specifying DocumentText causes this exception, and that appears to be as a result of calling the Refresh method (referenced above) when the browser has no contents (Last post here). A workaround for this is to set some mock contents and calling Application.DoEvents(). But even with this in place, it causes the above exception while loading the contents later on (done in another thread).

Note that the DocumentCompleted delegate I specify is being hit, but its WebBrowser.axIWebBrowser2.StatusText shows that the exception has occurred, and the WebBrowser.Document is empty.

I could put up a simple app to repro the issue, but I'd have to find a 2008 R2 instance where the bug is reproducible in order to debug. I'm more asking if anyone has ideas of what might be affecting or causing the issue, perhaps with relation to COM security etc.

Note that I am executing the WebBrowser in a STA Apartment state.

Any ideas or suggestions would be greatly appreciated. Thanks in advance! -Max

Andrei V
  • 7,306
  • 6
  • 44
  • 64
user851220
  • 1,071
  • 2
  • 7
  • 7

0 Answers0