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.
- In your Visual Studio, open the Options dialog (Tools > Options).
- In the Options dialog, select the debugging category and uncheck the option, “Require source files to exactly match the original version” and click OK.
Attaching to the K2HostServer.exe process
- Deploy your K2 process, if you have not done so.
- Open your process in Visual Studio.
- Right click on your Default Server Events (Codes), select View Code, followed by Event Item to view the codes.
- Add a breakpoint.
- In the menu, select DEBUG > Attach to process…
- 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.
- Next, click on the Select… button.
- In the Select Code type dialog, select Debug these codes types radio button and check Managed (v4.5, v4.0) and click OK.
- 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 =)
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.