views:

25

answers:

1

Hi Guys,

I'm trying to use the web browser control to open a url and get its HTML contents. You might ask why I'm not using the System.Net objects, the web pages are formatted through java scripts so the web browser control is the faster way but I can't seem to make it work. First, WebBrowser.Navigate won't fire when called. Please help.

BTW, I wrapped the web browser control from a class in a control library. Does web browser needs to be in a windows form type of assembly? I'm guessing that it has something to do with the message pump -- but I don't know completely. I also tried to house it in a form but still failed. Anyone's help is very much appreciated. I hope Jon Skeet can say something on this :).

A: 

Navigate is a method not an event, which event are you expecting to fire?

Yes the browser control expects a parent (otherwise it will have problems like this).
Since the browser control is also an STA component, it also expect a message pump (e.g. Application.Run( new FormMain() or formMain.ShowDialog()) in the current thread to raise events from the background thread.

See also

Sheng Jiang 蒋晟
Okay, my mistake of calling it 'firing'... should have been not functioning. You mentioned that the browser control expects a form to be the parent. Can you show an article about this? Or can you prove it to me? Thanks.
Jojo
BTW, i housed it in an invisible form but still the same.
Jojo