Using Web Browser control (AxShDocVw) to display app-generated HTML

O

Oenone

I've reached the conversion of a part of my application from VB6 to VB.NET
which uses the COM Web Browser control to display HTML content generated by
my application.

The general approach used in VB6 is as follows:

Open the form containing the browser
Wait a few seconds for the Browser.Document property to initialise
With the Document object, call the following methods:
.Clear()
.Open()
.Write(html)
.Close

This all works perfectly in VB6. In VB.NET however, I've been completely
unable to get this to work. The Document property of the Browser control is
always Nothing and no matter how long I wait it doesn't ever get set to an
object.

I also tried calling the Navigate() method of the browser object, and also
dropping URLs from other web browser windows into the browser control. In
each case a System.Runtime.InteropServices.MarshalDirectiveException
occurred with the message, "Marshaler restriction: Excessively long string."

Is there something special I need to do in order to use the Web Browser
control in my project?

Can anyone point me to some sample code that displays application-generated
HTML within the browser?

I could really use some help here as this is a critical part of my
application, without it my project will fail. :(

Thanks in advance,
 
O

Oenone

Oenone said:
This all works perfectly in VB6. In VB.NET however, I've been
completely unable to get this to work.

On further investigation, it appears to only be a problem if the form
containing the control is an MDI child form. If I don't set the MdiParent
property then the browser works acceptably (though it raises about a large
number of exceptions as the form opens).

I've tried setting the MdiParent both in the constructor of the Form, the
Load event, even after I set the HTML into the document, but each time the
browser just appears empty.

I can limp by with this operating as it currently is (looking longingly
towards the release of VS2005 with its built-in managed browser control) but
would love to know why this control is acting in the way it is! :)

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top