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

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

C#

if (System.Diagnostics.Debugger.IsAttached)
{
  System.Diagnostics.Debugger.Break();
}

VB

If System.Diagnostics.Debugger.IsAttached Then
  System.Diagnostics.Debugger.Break()
End If

2)  Export the process to the K2.net™ Server.
3)  

Edit the “K2Server.config” file, located by default in the path, “<drive>:\Program Files\K2.net 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 K2.net 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 K2.net™ 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: