使用Visual C#2010 Express在C#项目添加引用“SHDOCVW” [英] Add reference 'SHDocVw' in C# project using Visual C# 2010 Express

查看:1141
本文介绍了使用Visual C#2010 Express在C#项目添加引用“SHDOCVW”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面使用MS Visual Studio 2010和C#它创建了一个BHO的教程。为了运行本教程的代码,我要在我的项目添加此引用: -

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:-

使用SHDOCVW

但它不是用在添加引用.NET或COM部分。

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

所以我想问的就是这个名字空间不是在Microsoft Visual C#2010 Express中?
和如果它是可用的,如何进行添加。

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.

这是我的一半项目代码

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:-

错误1类型或命名空间名称'SHDOCVW'找不到(是否缺少使用指令或程序集引用?)

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

错误2类型或命名空间名称web浏览器找不到(是否缺少using指令或程序集引用?)

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

推荐答案

您需要添加一个引用到一个名为COM组件 Microsoft Internet控制

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

这篇关于使用Visual C#2010 Express在C#项目添加引用“SHDOCVW”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆