I am working on a Visual Studio plug-in. Given a VSLangProj.Reference, is there a way to programmatically determine if that reference is a project reference or a file reference?
Asked
Active
Viewed 984 times
2 Answers
0
This is what I've got so far:
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
}

Chris Xue
- 2,317
- 1
- 25
- 21
0
in VS 2008 the Reference Type has a property called SourceProject
Gets a Project object if the reference is a project. Otherwise, it returns Nothing (a null reference). Read-only.

Preet Sangha
- 64,563
- 18
- 145
- 216
-
I was sure that I tried that and it didn't give the proper results. But at your prompting I tried it again and it seems to be working properly after all. Thanks! – mreith Oct 19 '10 at 12:49
-
1A project (e.g. a .csproj) could have a ProjectReference but that project is not part of the solution in which case the **SourceProject** is null. Is there any other way to find out if this is coming from a "Reference" or "ProjectReference" without parsing through the csproj? – AndrewS May 02 '13 at 20:27