WinStudio

Debug a Script with Visual Studio

To debug using either of the procedures described here, WinStudio must be configured to use Visual Studio.

The procedures described in this topic apply to form scripts, but the main steps apply equally to global scripts.

Interactive Debugging

This section describes the debugging process if you leave Modeless dialog selected in the Settings window. This is the default.

NOTE: Interactive debugging is not available if you are using Visual Studio Express, because Visual Studio Express does not allow you to attach to an external application for debugging.

To debug a script using Visual Studio:

  1. Open a form and enter Design Mode.
  2. On the Edit menu, click Script Editor.
  3. In the WinStudio dialog box Editing Script in Visual Studio, select the Compile for Debug check box.
  4. Set a break point on the desired line in the script in the Visual Studio debugging session.
  5. Under the Visual Studio Debug menu in the debugging session, click Attach to Process.
  6. Select an instance of the WinStudio.exe process whose Type is TSQL, Managed, x86 and whose Title is Editing Script in Visual Studio.
  7. Click Attach.
  8. Minimize the Visual Studio debugging session.
  9. Perform an action in the form that calls the script.
    When the script is called and the breakpoint is encountered, focus changes to the Visual Studio debugging session attached to WinStudio. From this point, you can debug the script as you would debug any VB.NET code.
  10. When you are done debugging, on the Debug menu in the Visual Studio debugging session, click Stop Debugging.
  11. Close Visual Studio.
  12. Save the form definition.

Modal Debugging

This section describes the debugging process if you clear Modeless dialog in the Settings window.

To debug a script with WinStudio, you create a separate debugging session in Visual Studio 2010, attach the WinStudio process, and then call the script in WinStudio run mode. You can then debug the script in the debugging session.

To debug a script using Visual Studio:

  1. Open a form and enter Design Mode.
  2. On the Edit menu, click Script Editor.
  3. Close the Visual Studio IDE.
  4. In the WinStudio dialog box Editing Script in Visual Studio, select the Compile for Debug check box.
  5. Click Debug.
    If the script compiles successfully, it opens in another instance of Visual Studio, a "debugging session."
  6. Set a break point on the desired line in the script in the debugging session.
  7. Under the Visual Studio Debug menu in the debugging session, click Attach to Process.
  8. Select an instance of the WinStudio.exe process whose Type is TSQL, Managed, x86 and whose Title is Editing Script in Visual Studio.
  9. Click Attach.
  10. Minimize the Visual Studio debugging session.
  11. Click OK to close the Editing Script in Visual Studio dialog box.
  12. Exit WinStudio Design Mode.
  13. Perform an action in the form that calls the script.
    When the script is called and the breakpoint is encountered, focus changes to the Visual Studio debugging session attached to WinStudio. From this point, you can debug the script as you would debug any VB.NET code.
  14. When you are done debugging, on the Debug menu in the Visual Studio debugging session, click Stop Debugging.
  15. Close Visual Studio.
  16. Save the form definition.

Notes about Debugging

Only one instance of Visual Studio can be attached to WinStudio for debugging.

When you use modal debugging, if you make additional changes to the code you are debugging and attempt a second Debug compile of the modified code, you will receive a compile error similar to one of the following:

Compiling for Debug writes an assembly file (along with source and symbols) to disk. The error message indicates that the target assembly file cannot be overwritten because it is currently in use. In modal debugging, once an assembly is loaded into an application domain (in this case the global script domain or the form script domain), the only way it can be unloaded is to unload the domain. To unload a global script, select the WinStudio menu command Form > Definition > Unload all Global Form Objects. To unload a form script, close the form and reopen it. In interactive debugging, unloading form or global objects is not required.

When you use interactive debugging, you can recompile for debug as many times as you want without having to unload the form or global objects.


Related Topics

About Script Names in VB

Understanding Scripts in WinStudio