Debugging a script with Visual Studio

You can use the Visual Studio to debug a script either interactively or modally.

Note: Windows client must be configured to use Visual Studio.

The procedures apply to form scripts, but the main steps apply equally to global scripts.

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

Using modal and interactive 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 these:

  • "Unable to write output file 'C:\Documents and Settings\UserName\Local Settings\Application Data\Infor\WinStudio\GlobalScripts\ScriptName.dll.'"
  • "Compile Failed. If script compiles OK when Debug is not checked, try closing and reopening form or doing an unload global objects, and try again."

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 the global script domain or the form script domain, the only way you can unload the assembly is to unload the domain.

  • To unload a global script, you must select the Windows client menu command Form > Definition > Unload all Global Form Objects.
  • To unload a form script, close the form, then reopen the form.

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.

Initiating a form or global script debug session

You can initiate a form or a global script debug session within Visual Studio by using two different methods:

  1. Using Visual Studio Debug > Attach to process

    Managed Compatibility Mode is required when you attach Visual Studio to a Windows client instance. Managed Compatibility Mode can be set by using one of two ways:

    • You can select Use Managed Compatibility Mode under Options > Debugging > General to include Managed Compatibility Mode as an option when attaching to process.
    • Alternatively, if Managed Compatibility Mode is not set up under Options, you must verify that Managed Compatibility Mode code is specified in the Attach to Process > Attach to field. If this code type is not specified, you must click the Select button and select Managed (v4.6, v4.5, v4.0) and Manage Compatibility Mode codes.
  2. Using Visual Studio Debug > Start debugging

    You can use the Debug > Start option within Visual Studio to start a debug session. This option leverages the Windows client executable file that is added as one of the projects to the EditWinStudioScript Visual Studio solution. To use this option, you must right-click on WinStudio and select Set as StartUp Project. In the Attach and Use Legacy Managed Engine fields, specify Yes.

    With this setup, you can use the Debug > Start option to automatically attach the project to the existing WinStudio process. The Use Legacy Managed Engine option does the same process by using the legacy debug engine.