Falcons Myman
Falcons Myman

Reputation: 39

I'm getting error that i'm missing a reference but which one?

I added to the top of the form

using mshtml;

IHTMLDocument2 doc = (IHTMLDocument2)webbrowser1.Document.DomDocument;
            IHTMLControlRange imgRange = (IHTMLControlRange)((HTMLBody)doc.body).createControlRange();

The error is on:

(IHTMLControlRange)((HTMLBody)doc.body).createControlRange();

Error 3 One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?

Upvotes: 2

Views: 515

Answers (2)

Fᴀʀʜᴀɴ Aɴᴀᴍ
Fᴀʀʜᴀɴ Aɴᴀᴍ

Reputation: 6251

You need to add a reference to the Microsoft.mshtml assembly. Follow these steps to do so:

  • Project → Add Reference
  • Go to the Extensions tab (under Assemblies) on the left
  • Make sure the checkbox next to Microsoft.mshtml is checked.
  • Press OK.

Now everything should work fine.

You may see more than one entry for Microsoft.mshtml in the listed assemblies. In that case select any one of them (preferably the newest version).

Upvotes: 1

Rahul
Rahul

Reputation: 77876

Do remember that just by adding the statement Using mshtml; (considering that all the types used falls under mshtml dll) will not bring in the referenced dll. You will also need to add the reference of the dll to your project Reference folder.

Make sure you have done that.

Upvotes: 2

Related Questions