2010-07-30 73 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 

要你可能会考虑重构你的代码,这样可以更容易地处理较小的单位从长远来看,解决问题。

相关问题