一个宏( macro )
1.4 csharp
System.Diagnostics.Debugger.Break();
1.5 其他
可用NULL指针、除零操作等。
2. 定义自己的 assert 宏
String MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
MethodBase.GetCurrentMethod().Name MethodInfo.GetCurrentMethod().Name [Conditional("DEBUG")] void DebugFunc() { }
Shortcut Keys |
Descriptions |
Ctrl-Alt-V, A |
Displays the Auto window |
Ctrl-Alt-B |
Displays the Breakpoints dialog |
Ctrl-Alt-C |
Displays the Call Stack |
Ctrl-Shift-F9 |
Clears all of the breakpoints in the project |
Ctrl-F9 |
Enables or disables the breakpoint on the current line of code |
Ctrl-Alt-E |
Displays the Exceptions dialog |
Ctrl-Alt-I |
Displays the Immediate window |
Ctrl-Alt-V, L |
Displays the Locals window |
Ctrl-Alt-Q |
Displays the Quick Watch dialog |
Ctrl-Shift-F5 |
Terminates the current debugging session, rebuilds if necessary, and starts a new debugging session. |
Ctrl-F10 |
Starts or resumes execution of your code and then halts execution when it reaches the selected statement. |
Ctrl-Shift-F10 |
Sets the execution point to the line of code you choose |
Alt-NUM * |
Highlights the next statement |
F5 |
If not currently debugging, this runs the startup project or projects and attaches the debugger. |
Ctrl-F5 |
Runs the code without invoking the debugger |
F11 |
Step Into |
Shift-F11 |
Executes the remaining lines out from procedure |
F10 |
Executes the next line of code but does not step into any function calls |
Shift-F5 |
Available in break and run modes, this terminates the debugging session |
Ctrl-Alt-H |
Displays the Threads window to view all of the threads for the current process |
F9 |
Sets or removes a breakpoint at the current line |
Ctrl-Alt-W, 1 |
Displays the Watch 1 window to view the values of variables or watch expressions |
Ctrl-Alt-P |
Displays the Processes dialog, which allows you to attach or detach the debugger to one or more running processes |
Ctrl-D,V |
IntelliTrace Event |
对话框
System.Windows.Forms.MessageBox.Show("Exception at File:Line:\n" + ExceptionToStr(e));
Dim objIEDebugWindow
Debug "This is a great way to display intermediate results in a separate window."
Sub Debug( myText )
' Uncomment the next line to turn off debugging
' Exit Sub
If Not IsObject( objIEDebugWindow ) Then
Set objIEDebugWindow = CreateObject( "InternetExplorer.Application" )
objIEDebugWindow.Navigate "about:blank"
objIEDebugWindow.Visible = True
objIEDebugWindow.ToolBar = False
objIEDebugWindow.Width = 200
objIEDebugWindow.Height = 300
objIEDebugWindow.Left = 10
objIEDebugWindow.Top = 10
Do While objIEDebugWindow.Busy
WScript.Sleep 100
Loop
objIEDebugWindow.Document.Title = "IE Debug Window"
objIEDebugWindow.Document.Body.InnerHTML = _
"<b>" & Now & "</b></br>"
End If
objIEDebugWindow.Document.Body.InnerHTML = _
objIEDebugWindow.Document.Body.InnerHTML _
& myText & "<br>" & vbCrLf
End Sub
Notes: | (1) | objIEDebugWindow must be declared in the main script body, not in the subroutine (must be global)! |
(2) | Do not discard the objIEDebugWindow object at the end of the script, or your debug window will vanish! |