Skip to main content
We currently have a web site at, say, www.test.local. We have compiled several .NET components and installed them in the bin folder off the root of the web site. We have a configuration class which reads the web.config file and caches the configurtion information in public static properties within the class.

The problem is that when I try to access the config component from inside a K2 workflow module (within K2 Studio), the confguration component is not finding the web.config file. I put in some test code to write out a file from inside the config component. It writes out two files: one to "c:windowssystem32inetsrv" when the web page accesses it, and another to "c:program filesk2.net 2003in" when the k2server process accesses it.

Question is how can we get this component to read the web site's config file from inside K2 Server? And where is the documentation on the configuration settings in the k2 .config files?
When the need to access user objects/dependant files etc. arises the following may be implemented.

When K2Server executes user-code/objects exported/referenced from K2Studio, the K2Server's process's execution directory is the folder where the actual K2Server.exe is executing from. e.g.

"C:Program FilesK2.net 2003Bin"

The following code-snippet may assist in this matter seeing that the .NET framework allows us to momentarily alter these environment identifiers to allow custom folder/file access. e.g.

// First, we get a handle on the current execution environment.
String K2Path = System.IO.Directory.GetCurrentDirectory().ToString();

// Now we modify our environment momentarily for custom access.
System.IO.Directory.SetCurrentDirectory("C:INETPUBWWWROOT");
// We access our user-object dependecies etc. Do some work...

// Now, we Reset our environment identifiers etc. back to the original state and continue to do some more work if need be..
System.IO.Directory.SetCurrentDirectory(K2Path);

Reply