65.9K
CodeProject is changing. Read more.
Home

modds Drag and Drop Programming for C# Debugging (Part 4)

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Aug 2, 2016

CPOL

2 min read

viewsIcon

9650

Visual Programming Language

Introduction

In modds Drag and Drop Programming for C# Sample Stock Chart Auto Completion (part 3), I show an example of adding auto completion to Stock Chart Program. As the program gets more complicated, we need ways to debug and step into the codes. 

Project Requirements

Debugging the modds Project

Simple Pop Up Windows

With modds Designer, you can use Inspection Tools->ToStringMessageBox at Control Toolbox panel to check if a control receives data or not.

Example: Connect a Message Box to SearchCommand on StockChartAutoComplete example.

In this example, the black line's connection index is set to 0 and the blue line's connection index is set to 1. This means the data will flow to Message Box first before it flows to YahooDailyMarketData.

On StockChartAutoComplete program UI, the search button is data binded to SearchCommand control.  When user presses the search button, the Message Box will pop up. The Message Box will stop the data flow until user presses the OK button in it. This is the simplest way to see if you have a data flow on connected control.

Generated Code

When modds program compiled in DEBUG mode, all code written with Scripts->C# Script control will generate a .cs file. Those files are located at Project Director-> Build->Debug->Scripts->ProgramScript-><Module filename.cs>.

You can use Microsoft Visual Studio to open the .cs file and set break point on it. 

Step In To the Generated Code

  1. Using modds Designer to open StockChartAutoComplete example project.
  2. Right click on the project and select Debug to run.
  3. Using Microsoft Visual Studio to open the following .cs file.

    StockChartAutoComplete(Director)->Build->Debug->Scripts->ProgramScript->MainWindows.cs

  4. Set break point at the beginning of function GetKeyInText.
  5. At Microsoft Visual Studio Debug->Attach to Process… to attach the running program StockChartAutoComplete
  6. On StockChartAutoComplete execution window, type a character at Stock textbox.

The Microsoft Visual Studio should break at GetKeyInText function.

Start Debugger at Program Startup

On StockChartAutoComplete project, the Log.xsml object instance is created at program startup.

Open StockChartAutoComplete project and open(double click) Application.moddc.  You can see the following line:

 <PreloadObject Path="Schema\Log.xsml" /> 

The PreloadObject line tells modds object builder to create the path module object before creating the MAIN object. In this example, the Log.xsml is created before the MAIN (MainWindow.xsml). We can launch the Microsoft Debugger at Log.xsml.

  1. Open Log.xsml
  2. On Control Toolbox panel, drag in modds Common Controls->Start Trigger
  3. On Control Toolbox panel, drag in Scripts->C# Script and enter the following code
Using Panel
using System;
using System.Diagnostics;
Code Panel
static public void StartDebugger()
{
    Debugger.Launch();
}

Connect controls as follows:

Run StockChartAutoComplete in Debug, the Microsoft Visual Studio will start and attach to the running program.

modds Drag and Drop Programming for C# Creating Class Library (DLL) - Part 5