SolutionBuild2.StartupProjects 属性

获取或设置作为应用程序入口点的项目的名称。

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

语法

声明
Property StartupProjects As Object
    Get
    Set
Object StartupProjects { get; set; }
property Object^ StartupProjects {
    Object^ get ();
    void set (Object^ value);
}
abstract StartupProjects : Object with get, set
function get StartupProjects () : Object
function set StartupProjects (value : Object)

属性值

类型:System.Object
一个对象,包含作为应用程序入口点的项目的名称。

实现

SolutionBuild.StartupProjects

备注

StartupProjects 包含当发出 Run 命令时启动的项目名称字符串的列表。 每个项目和语言都定义了启动的含义,以及项目启动时发生的情况。 例如,通过执行 main() 函数可启动 Visual C++ 项目,而 Visual Basic 执行 Sub Main() 或一个启动窗体。 其他项目和语言使用类的项目属性或函数名,而还有一些项目和语言使用必须实现的接口等。

示例

此示例确定每个活动启动配置的生成状态。 在运行此外接程序之前,在 Visual Studio 集成开发环境 (IDE) 中打开项目。

有关如何作为外接程序运行此示例的更多信息,请参见 如何:编译和运行自动化对象模型代码示例

Imports EnvDTE
Imports EnvDTE80
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)
    SolutionBuild2Example(_applicationObject)
End Sub
Sub SolutionBuild2Example(ByVal dte As DTE2)
    ' Open a solution in the Visual Studio IDE
    ' before running this example.
    Try
        Dim sb As SolutionBuild2
        sb = CType(_applicationObject.Solution.SolutionBuild _
        , SolutionBuild2)
        Dim sc As SolutionConfiguration2
        sc = CType(sb.ActiveConfiguration, SolutionConfiguration2)
        Dim vsBldSt As vsBuildState
        Dim msg As String = "Return relative path to startup  _
        projects: "
        For Each s As String In CType(sb.StartupProjects, Array)
            msg &= vbCr & " " & s
        Next
        msg &= vbCr & "SolutionConfiguration: " & sc.Name
        vsBldSt = sb.BuildState
        If (vsBldSt = vsBuildState.vsBuildStateDone) Then
            msg &= vbCr & "A build has occurred."
        ElseIf (vsBldSt = vsBuildState.vsBuildStateInProgress) Then
            msg &= vbCr & "A build is in progress."
        Else : msg &= vbCr & "A build has not occurred."
        End If
        MsgBox(msg)
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    SolutionBuild2Example(_applicationObject);
}
public void SolutionBuild2Example(DTE2 dte)
{
    try
    {
        SolutionBuild2 sb =
 (SolutionBuild2)_applicationObject.Solution.SolutionBuild;
        SolutionConfiguration2 sc =
 (SolutionConfiguration2)sb.ActiveConfiguration;
        vsBuildState vsBS;
        string msg = "Return relative path to startup projects: ";
        foreach (String s in (Array)sb.StartupProjects)
        {
            msg += "\n   " + s;
        }
        msg += "\nSolutionConfiguration: " + sc.Name;
        vsBS = sb.BuildState;
        if (vsBS == vsBuildState.vsBuildStateDone)
            msg += "\nA build has occurred.";
        else if (vsBS == vsBuildState.vsBuildStateInProgress)
            msg += "\nA build is in progress.";
        else msg += "\nA build has not occurred.";
        MessageBox.Show(msg);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

请参见

参考

SolutionBuild2 接口

StartupProjects 重载

EnvDTE80 命名空间