Cannot convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.HTMLDocument'

  • Thread starter Thread starter Paul Hemans
  • Start date Start date
P

Paul Hemans

I am very new at .Net. I have a small project where I need to manipulate the
contents of a web page.

I have a form with a web browser control (webBrowser1) on it. Within the
webBrowser1_DocumentCompleted method I have the following code.

mshtml.HTMLDocument oDoc = new HTMLDocumentClass();

oDoc = (mshtml.HTMLDocument)webBrowser1.Document;

This is generating the error:

C:\learning\c#\myProject\myProject\Form1.cs(53,24): error CS0030: Cannot
convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.HTMLDocument'



Can you give me any ideas on what I am doing wrong?
 
Hello,

I am looking for same information.

Thanks
ML

P.S. Paul, please update the answer here if you find it. Thanks
 
To solve that error I replaced the 2 lines:
mshtml.HTMLDocument oDoc = new HTMLDocumentClass();

oDoc = (mshtml.HTMLDocument)webBrowser1.Document;

with:
HtmlDocument oDoc = webBrowser1.Document;
 

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

Back
Top