Tag Archives: Visual Studio

K2 blackpearl: How to debug your Default Server Event (Codes) in Visual Studio 2013

There are¬†times when you need to write codes in your K2 workflow to provide features that is not available out-of-box. It could be a complex logic processing, sending of formatted HTML email with table contents, etc. In this article, I’m going to show you how to attach to the K2HostServer.exe process to debug your workflow.


  1. In your Visual Studio, open the Options dialog (Tools > Options).

    Tools > Options
  2. In the Options dialog, select the debugging category and uncheck the option, “Require source files to exactly match the original version” and click OK.
    Uncheck “Require source files to exactly match the original version”


Attaching to the K2HostServer.exe process

  1. Deploy your K2 process, if you have not done so.
  2. Open your process in Visual Studio.
  3. Right click on your Default Server Events (Codes), select View Code, followed by Event Item to view the codes.

    Default Server Event (Codes) > View Code > Event Item
  4. Add a breakpoint.

    Add a break point in your codes.
  5. In the menu, select DEBUG¬†> Attach to process…

    DEBUG > Attach to Process…
  6. In the Attach to Process dialog, select K2HostServer.exe under Available Processes. You may need to check the “Show processes from all users” if you are not logged in as the K2 Service account.

    Select K2HostServer.exe process
  7. Next, click on the Select… button.

    Click on the Select… button
  8. In the Select Code type dialog, select Debug these codes types radio button and check Managed (v4.5, v4.0) and click OK.

    Select Managed (v4.5, v4.0)
  9. Click on the Attach button and we are ready to test the workflow!

    Note: Don’t worry if the symbols are not loaded after you attached to the process. It will do so when the workflow kicks off.



Start your workflow running and wait for the breakpoint to hit. When it does, it is up to your debugging skills to find your problem now =)

Time to debug!

Just a side note, if you are running the K2 blackpearl Server service in console mode, your Console.WriteLines will appear in the console too.

Console.WriteLine shown in K2 blackpearl Server console


Happy Debugging!