如何确定VSLangProj.Reference是项目引用还是文件引用?

时间:2010-10-17 22:33:00

标签: c# visual-studio visual-studio-addins

我正在使用Visual Studio插件。给定一个VSLangProj.Reference,有没有办法以编程方式确定该引用是项目引用还是文件引用?

2 个答案:

答案 0 :(得分:0)

VS 2008 the Reference Type has a property called SourceProject

中的

如果引用是项目,则获取Project对象。否则,它返回Nothing(空引用)。只读。

答案 1 :(得分:0)

这是我到目前为止所得到的:

if (reference.Type == prjReferenceType.prjReferenceTypeActiveX)
{
    // reference is a COM object
}
else if (reference.SourceProject != null)
{
    // reference is a project in the solution
}
else if (!string.IsNullOrEmpty(reference.Path))
{
    // "reference" is either
    // an valid external dll
    // or a project that is not in the solution and is referenced by a C++ project
}
else
{
    // reference is either
    // a project not in the solution
    // or an external dll with invalid path
}