Reference3.AutoReferenced 屬性
更新:2007 年 11 月
取得編譯器 (Compiler) 是否會自動參考此參考。
命名空間: VSLangProj80
組件: VSLangProj80 (在 VSLangProj80.dll 中)
語法
ReadOnly Property AutoReferenced As Boolean
Dim instance As Reference3
Dim value As Boolean
value = instance.AutoReferenced
bool AutoReferenced { get; }
property bool AutoReferenced {
bool get ();
}
function get AutoReferenced () : boolean
屬性值
boolean 值,指出是否已自動參考此參考。
備註
編譯器會自動使用某些參考。例如,Visual Basic 專案會自動參考 MSCORLIB.dll 和 Microsoft.VisualBasic.dll。
範例
此範例會在開啟的 Visual Basic、Visual C# 或 Visual J# 專案中逐一查看參考。然後會判斷是否要自動參考這些參考。若要將此範例當做增益集來執行,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例。
Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object,_
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
applicationObject = CType(application, DTE2)
addInInstance = CType(addInInst, AddIn)
DisplayAutoReferenced(applicationObject)
End Sub
Public Sub DisplayAutoReferenced(ByVal dte As DTE2)
' The first project is a Visual Basic, C#, or J# project.
Dim vsProject As VSProject2 = CType(applicationObject.Solution.Projects.Item(1).Object, VSProject2)
Dim aRef As Reference3
Dim refStr As String
refStr = ""
For Each aRef In VSProject.References
refStr += (aRef.Name & " has an AutoReferenced value of: " _
& aRef.AutoReferenced.ToString() & vbCr & vbCr)
Next
MsgBox(refStr)
End Sub
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
applicationObject = (DTE2)application;
addInInstance = (AddIn)addInInst;
DisplayAutoReferenced(((DTE2)applicationObject));
}
public void DisplayAutoReferenced(DTE2 dte)
{
// The first project is a Visual Basic, C#, or J# project.
VSProject2 aProject =
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
Reference3 aRef = null;
string refStr = null;
refStr = "";
foreach (VSLangProj80.Reference3 temp in aProject.References)
{
aRef = temp;
refStr += (aRef.Name + " has an AutoReferenced value of : "
+ aRef.AutoReferenced.ToString() + "\n" + "\n");
}
MessageBox.Show(refStr);
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。