开发者

.NET WebBrowser component hanging when loading a new HTML page

we have embedded the .NET WebBrowser control (actually two in different tabs, if that for some reason may be important) in a dialog and are running into a strange problem. I have not been able to reproduce the problem outside the complete application, so I assume we're doing something with side-effects elsewhere. Because of this, I am not able to post any code to reproduce the problem, but I 开发者_开发问答was still hoping that someone may at least have a suggestion on how to debug the situation and perhaps find the reason for the component to fail.

Usually, everything works as expected. We add the control to our dialog and invoke its Navigate method to get an HTML page from a server. In some cases (perhaps 20-25% of the attempts), the control stays blank and keeps displaying the waiting cursor. The problem is not reproducible, when loading the same URL from a standalone IE.

In an attempt to locate the problem, we are logging the Navigating, Navigated, DocumentCompleted, ProgressChanged and StatusTextChanged events. In the situations where it works, we see the Navigating, Navigated and DocumentCompleted events in this order and several ProgressChanged and StatusTextChanged events (with reasonable values) mixed in between.

In the situations where the component fails, only the Navigating event is fired. Both the server log and a network dump confirms however, that the document is requested and delivered correctly from the server. Malformed or illegal content is of course at least a theoretical possibility, but I would have expected at least a Navigated event from the component, before it even tries to analyze whatever the server is delivering. We are also able to reproduce both successful and failing behaviour with exactly the same HTML document.

So back to my original question: The description of the situation is perhaps a little thin and I don't expect a finished solution for this problem, but can someone perhaps at least suggest where to look and what to look for? I am not too experienced with .NET development, but since the WebBrowser probably is just a thin layer around IE's ActiveX component, I doubt that I'm able to debug into its internals to find any probable causes for the problem?


Might be worth your while trying out this different webbrowser component on CodeProject...it's different in that there's more functionality that you can do with it. It would be a useful test to check if it works with this extended version of the webbrowser control.

Hope this helps, Best regards, Tom.


I guess I have to answer myself on this one. Although I'm not very satisfied with workarounds for problems I don't understand and not even understanding why a workaround works, we managed to modify the code, so that we're at least not able to reproduce the strange behaviour. The trick was invoking Navigate("about:blank"); before invoking Navigate with the real URL.

I assume that the workaround solved some kind of timing or concurrency problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜