This article explains how to run™ 2003 Server code in "Debug" mode using Microsoft® Visual Studio .NET.

In order to debug server event code on a™ 2003 Server, the following steps need to be taken:
1)  In™ 2003 Studio, add the following code snippet to your™ event code for the activity that requires debugging, (In the attached sample process, this code was added to the “Server Code” event).


if (System.Diagnostics.Debugger.IsAttached)


If System.Diagnostics.Debugger.IsAttached Then
End If

2)  Export the process to the™ Server.

Edit the “K2Server.config” file, located by default in the path, “<drive>:\Program Files\ 2003\Bin”, using a text editor such as Notepad. Add the following line to the K2Server.config file:

<Debug Enable="True" />

4)  Stop and restart the 2003 Server Service using the Services application, as shown:
5)  Attach the “K2Server.exe” process to the Visual Studio .NET debugger as follows:
  a)  In Microsoft® Visual Studio .NET, select “Tools”, followed by “Debug Processes…” from the toolbar.
  b)  The “Processes” window will appear. Browse to the “K2Server.exe” process, select it and then click “Attach...”.
Note: if the K2Server.exe process does not appear, tick the options “Show system processes” and “Show processes in all sessions”.
  c)  The “Attach to Process” window will appear. Select the “Common Language Runtime” option and click “OK”, as illustrated:
  d)  The “K2Server.exe” process will now be listed under the “Debugged Processes” section of the “Processes” window, as shown:
  e)  Visual Studio .NET will now be running in “Debug” mode. Leave Visual Studio .NET open.
6)  Start the process that requires debugging, (this may be via a™ 2003 Smartform or via some code, depending on the solution). When the server encounters the breakpoint inserted in step (1), Visual Studio .NET will break execution and the server event code can then be stepped through in “Debug” mode: