Debugger.CurrentProgram 屬性

設定或取得現用的程式。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
Property CurrentProgram As Program
    Get
    Set
Program CurrentProgram { get; set; }
property Program^ CurrentProgram {
    Program^ get ();
    void set (Program^ value);
}
abstract CurrentProgram : Program with get, set
function get CurrentProgram () : Program
function set CurrentProgram (value : Program)

屬性值

型別:EnvDTE.Program
現用的 Program

備註

CurrentProgram 會設定或傳回現用的 Program。 現用的程式是定義偵錯工具所顯示資料的程式。 雖然偵錯工具支援同時偵錯一個以上處理序,但在任何時候都只有一個處理序是現用的。 如需詳細資訊,請參閱偵錯多重處理序

範例

下列範例示範如何使用 CurrentProgram 屬性。

若要測試這個屬性:

  1. 開啟目標應用程式。 執行增益集。 沒有在偵錯程式。

  2. 在目標應用程式中設定中斷點。 以偵錯模式執行應用程式。

  3. 當程式在中斷點上停止時,請執行增益集。 程式正在進行偵錯。

public static void CurrentProgram(DTE dte)
{
    // Setup the debug Output window.
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Current Program Test");
    owp.Activate();

    owp.OutputString("Current Program Info: ");
    EnvDTE.Program program = dte.Debugger.CurrentProgram;
    if(program == null)
        owp.OutputString("No program is being debugged");
    else
        owp.OutputString("Program Name = " + program.Name);
}
Shared Sub CurrentProgram(ByRef dte As EnvDTE.DTE)
    Dim program As EnvDTE.Program = dte.Debugger.CurrentProgram
    If program Is Nothing Then
        MessageBox.Show("No program is being debugged", _
                        "Debugger Test - Current Program Info")
    Else
        MessageBox.Show("Program Name = " + _
                        program.Name, "Debugger Test - Current Program Info")
    End If
End Sub

.NET Framework 安全性

請參閱

參考

Debugger 介面

EnvDTE 命名空間

Debugger