Console Application. Commands Debugging

There are several approaches to debug developed Commands:

  • Use the DevExpress tracing protocol
  • Customize in Visual Studio a project that contains a code of developed Command
  • Use RunCmd.exe with /debug key  

DevExpress Tracing Protocol

During its operation, the RunCmd.exe error log is  using class DevExpress.Persistent.Base.Tracing.

During working, RunCmd.exe logs the error using DevExpress.Persistent.Base.Tracing class. There is a <system.diagnostics> section in the config-file of the application, it allows to turn on/off the protocol and configure the level of detail.

The following snippet demonstrates a configuration example in Verbose mode:

  • xml

<system.diagnostics>
     <switches>
      <!-- Use the one of predefined values: 0-Off, 1-Errors, 2-Warnings, 3-Info, 4-Verbose. The default value is 3. -->
      <add name="eXpressAppFramework" value="4" />
     </switches>
  </system.diagnostics>

Progect Customization

  • Invoke Solution Explorer and focus the project (module), which implements the command. Right-click the progect item and choose "Set as StartUp Project" option.
  • Navigate to the project properties. Select Debug tab. Set Start Action option to the "Start external program" value, specify the path to the RunCmd.exe file that will be used for debugging. Set required arguments to the Command line arguments area.

run_cmd_2

  • In the Visual Studio main menu navigate to the TOOLS|Options|Debugging|General item and uncheck "Enable Just My Code" option.
  • If necessary, specify the path to the file with debugging information (.pdb files). To do this, navigate to the TOOLS|Options|Debugging|Symbols menu item.

run_cmd_3

  • If necessary, set breakpoints in code .
  • If necessary, allow the debugger to break when exceptions occur. To do this, navigate to the Debug|Exceptions menu item and check the box for Common Language Runtime Exceptions.
  • Start debugging the project: DEBUG|Start Debugging or "F5".

/debug Key

RunCmd.exe utility supports /debug parameter for command line. Starting with this key will show the message: "Can attach a debugger and press any key..." Further, the utility waits for any key. During this time, you can connect an external debugger (DEBUG|Attach to Process...).

Debug mode prints to the console information about the exception. In parallel it draws up the log using DevExpress.Persistent.Base.Tracing.