EnvDTE.CodeNamespace会员为空?

EnvDTE.CodeNamespace members are empty?

我试图在活动文档中找到一个函数,但是我遇到了一个问题,当函数在命名空间内时,我的代码试图获取 EnvDTE.CodeNamespace 对象的成员,但是它returns 空的,我也试过 Children,但它也是空的。

http://www.mztools.com/articles/2006/MZ2006009.aspx

我的代码一般是这段代码的C#实现。它挣扎于 ;

If TypeOf objCodeElement Is EnvDTE.CodeNamespace Then
   colCodeElements = CType(objCodeElement, EnvDTE.CodeNamespace).Members

此函数 returns 清空 CodeElements。知道如何解决吗?

P.S:我的扩展在 C++ 文件上运行。

编辑:发布测试代码。

#include "stdafx.h"
#include "Header.h"
namespace ns_deneme{
    int zaza::func_deneme(int k)
    {
        a = k;
        return a;
    }
}

int wmain(int argc, wchar_t* argv[])
{
    xaxa a;
    int ba = a.deneme2(5);
}

int xaxa::deneme2(int a){
    return a;
}

Header.h

namespace ns_deneme{
    class zaza{
        private:
            int a;
            int func_deneme(int k);
    };
}

class xaxa{
public:
    int deneme2(int a);
};

问题是它确实在 cpp 文件中找到了 wmain 和 deneme2 的功能(头文件也不起作用,它给出了 -over range 等-),但 cpp 文件中的 deneme 也不起作用。

我推荐一种获取当前函数的不同方法:

    EnvDTE.TextSelection ts = DTE.ActiveWindow.Selection as EnvDTE.TextSelection;
    if (ts == null)
        return;
    EnvDTE.CodeFunction func = ts.ActivePoint.CodeElement[vsCMElement.vsCMElementFunction]
                as EnvDTE.CodeFunction;
    if (func != null)
      System.Windows.MessageBox.Show(func.FullName);