2010-10-17 57 views

回答

0

VS 2008 the Reference Type has a property called SourceProject

獲取一個項目的對象如果給定的項目。否則,它返回Nothing(空引用)。只讀。

+0

我確信,我試過了,並沒有給出正確的結果。但在你的提示中,我再次嘗試了一遍,看起來它正在正常工作。謝謝! – mreith 2010-10-19 12:49:18

+0

哈哈 - 適用於我的機器類型的東西。 – 2010-10-19 20:06:23

+1

項目(例如.csproj)可能具有ProjectReference,但該項目不是解決方案的一部分,在這種情況下** SourceProject **爲空。是否有任何其他方式來查明這是否來自「參考」或「ProjectReference」而不通過csproj解析? – AndrewS 2013-05-02 20:27:42

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 
}