Question

i'm developing a project which fetch some information from web to windows form so i'm using mshtml reference . so i can convert the document in below way

Dim docDell As HTMLDocument = CType(WebBrowser1.Document.DomDocument, mshtml.HTMLDocument)

above code works great !

but when i try the below code its shows the warning message*(runtime error might occur when converting 'system.windows.forms.htmldocument' to mshtml.IhtmlDocument)*

Dim newdoc As HTMLDocument = WebBrowser1.Document

Is that any way to use both in same project ...

Hope i explained well ..

Was it helpful?

Solution

You can use both in the same project. You just need to be careful about which namespace you are using. Since System.Windows.Forms.HtmlDocument and mshtml.HtmlDocument both share the same class name, you need to make sure you are using the correct one by specifying the right namespace.

Here's how you'd get the two objects from the same WebBrowser:

Dim unmanagedDoc As mshtml.HtmlDocument = DirectCast(WebBrowser1.Document.DomDocument, mshtml.HTMLDocument)
Dim managedDoc As System.Windows.Forms.HtmlDocument = WebBrowser1.Document
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top