2010-07-30 70 views

回答

0

您可以編寫一個Visual Studio宏,以便在文件中每個方法的開頭添加一個斷點。

宏看起來會沿着這個線路:

Imports System 
Imports EnvDTE 
Imports EnvDTE80 
Imports EnvDTE90 
Imports EnvDTE90a 
Imports EnvDTE100 
Imports System.Diagnostics 

Public Module Module1 
    Public Sub AddBreakpointForCurrentMethod() 
     Dim textSelection As EnvDTE.TextSelection 
     Dim codeElement As EnvDTE.CodeElement 

     textSelection = DTE.ActiveWindow.Selection 
     Try 
      codeElement = textSelection.ActivePoint.CodeElement(vsCMElement.vsCMElementFunction) 
      If Not (codeElement Is Nothing) Then 
       DTE.Debugger.Breakpoints.Add(Line:=codeElement.StartPoint.Line, File:=DTE.ActiveDocument.FullName) 
      End If 
     Catch 
      MsgBox("Add error handling here.") 
     End Try 
    End Sub 

End Module 

要你可能會考慮重構你的代碼,這樣可以更容易地處理較小的單位從長遠來看,解決問題。