K2 and .Net 4

23 Mar

Using K2 in a .Net 4 environment is fairly simple, but there are 2 things you need to do to get it to work.

Edit Config Files
  1. Open K2HostServer.config file and add this to the <appSettings>:
    <add key="netfxversion" value="v4.0.30319" />
  2. Open the K2Server.config file and change the .Net version to read as follows:
    <Framework Version="v4.0.30319" />
  3. Open K2.Setup file and change the .Net version to read as follows:
    <Framework Version="v4.0.30319" />
  4. Restart the service
But if you are using a config file…

This came as a bit of a surprise. If you’re referencing a dll which uses a config file then you need to add a reference to this config file in K2HostServer.config because the dll will be loaded in the K2 services’ context (See this post for more about how to do this). The problem is, however, that as soon as you’re referencing a .Net 4 dll this doesn’t work anymore. After much searching, hacking and frustration I found a workaround. Here’s what you do:

  1. Create a config file in the same folder as K2HostServer.config. Name it K2HostServer.exe.config
  2. Add your config file reference to K2HostServer.exe.config and not K2HostServer.config.

Voila. It works. I raised a ticket for this and it seems this is a .Net bug – read here and here for more info.

Hope that helps!

Update: I have verified my approach with K2 and they have confirmed that this approach is both supported and will be the recommended approach.
Another Update: This will work if you’re referencing dll’s from your processes but not if you’re referencing dll’s from a custom security provider. If you’re referencing dll’s from a security provider, you need to add the config entries in K2HostServer.config, not K2HostServer.exe.config.


Posted by on March 23, 2011 in SmartObjects


2 Responses to K2 and .Net 4

  1. Erlangga

    October 17, 2011 at 5:52 am

    Thank you very much for this.
    I have spent at least 48 hours debugging this last week.

  2. Trent Jacobs

    October 17, 2011 at 11:03 pm


    No probs.


Leave a Reply

Your email address will not be published. Required fields are marked *