Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add reference 'SHDocVw' in C# project using Visual C# 2010 Express

Tags:

I am following a tutorial which creates a BHO using MS Visual Studio 2010 and C#. In order to run the tutorial code, I have to add this reference in my project:-

using SHDocVw

But it is not available in .NET or COM section in Add References.

So I wanted to ask is this namespace not available in Microsoft Visual C# 2010 Express? and if it is available, how to add it.

This is my halfway project code

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace IEPlugin {  [     ComVisible(true),     InterfaceType(ComInterfaceType.InterfaceIsIUnknown),     Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352") ] public interface IObjectWithSite {     [PreserveSig]     int SetSite([MarshalAs(UnmanagedType.IUnknown)]object site);     [PreserveSig]     int GetSite(ref Guid guid, out IntPtr ppvSite); } [     ComVisible(true),     Guid("2159CB25-EF9A-54C1-B43C-E30D1A4A8277"),     ClassInterface(ClassInterfaceType.None) ]  public class BHO : IObjectWithSite {     private WebBrowser webBrowser;      public int SetSite(object site)     {         if (site != null)         {             webBrowser = (WebBrowser)site;             webBrowser.DocumentComplete +=               new DWebBrowserEvents2_DocumentCompleteEventHandler(               this.OnDocumentComplete);         }         else         {             webBrowser.DocumentComplete -=               new DWebBrowserEvents2_DocumentCompleteEventHandler(               this.OnDocumentComplete);             webBrowser = null;         }          return 0;      }      public int GetSite(ref Guid guid, out IntPtr ppvSite)     {         IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);         int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);         Marshal.Release(punk);         return hr;     }      public void OnDocumentComplete(object pDisp, ref object URL)     {         HTMLDocument document = (HTMLDocument)webBrowser.Document;     }  } 

}

Here are the errors attached:-

Error 1 The type or namespace name 'SHDocVw' could not be found (are you missing a using directive or an assembly reference?)

Error 2 The type or namespace name 'WebBrowser' could not be found (are you missing a using directive or an assembly reference?)

like image 278
Saad Sarwar Avatar asked Dec 30 '13 18:12

Saad Sarwar


1 Answers

You need to add a reference to a COM component called Microsoft Internet Controls.

enter image description here

like image 139
X3074861X Avatar answered Oct 02 '22 11:10

X3074861X