Reference3.AutoReferenced 属性

获取是否由编译器自动引用该引用。

命名空间:  VSLangProj80
程序集:  VSLangProj80(在 VSLangProj80.dll 中)

语法

声明
ReadOnly Property AutoReferenced As Boolean
bool AutoReferenced { get; }
property bool AutoReferenced {
    bool get ();
}
abstract AutoReferenced : bool
function get AutoReferenced () : boolean

属性值

类型:System.Boolean
一个指示是否对引用进行自动引用的 boolean 值。

备注

有些引用由编译器自动使用。例如,Visual Basic 项目会自动引用 MSCORLIB.dll 和 Microsoft.VisualBasic.dll。

示例

此示例循环访问打开的 Visual Basic 或 Visual C# 项目中的引用。然后确定这些引用是否为自动引用。若要将此示例作为外接程序运行,请参见如何:编译和运行自动化对象模型代码示例

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 or C# 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 or C# 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);
}

.NET Framework 安全性

请参见

参考

Reference3 接口

VSLangProj80 命名空间