In some 2008 R2 environments, and not in others, I get COMExceptionswhen using the control System.Windows.Forms.WebBrowser. Regardless of whether to specify content through a property DocumentTextor call a method Navigatewith a URL parameter, I get the same exception:
COMException - HRESULT error E_FAIL was returned from a call to the COM component.
at System.Windows.Forms.UnsafeNativeMethods.IWebBrowser2.Refresh()
I found that setting the property ScrollBarsEnabledto WebBrowserbefore pointing out DocumentTextthrows this exception, and it looks like it's caused by a method call Refresh(mentioned above) when the browser has no content (last post here ). A workaround for this is to set some content layout and call Application.DoEvents(). But even with this in place, it throws the aforementioned exception when loading content later (executed in another thread).
Please note that the delegate DocumentCompletedI indicate, but it WebBrowser.axIWebBrowser2.StatusTextshows that this event happened, but is WebBrowser.Documentempty.
I could host a simple application to recheck the problem, but I would need to find an instance of 2008 R2 where the error is reproduced for debugging. I ask more if anyone has any ideas on what might affect or cause the problem, possibly regarding COM security, etc.
Please note that I am performing WebBrowserin a state STA Apartment.
Any ideas or suggestions would be greatly appreciated. Thanks in advance! -Max
source
share