TaskEnvironmentSetConfigurationString Method

Specifies the .NET configuration as a string to load into the host application domain during task execution.
Namespace:  AGI.Parallel.Infrastructure
Assembly:  AGI.Parallel.Infrastructure (in AGI.Parallel.Infrastructure.dll) Version: (
public void SetConfigurationString(
        string configurationString


Type: SystemString
The configuration string.
using System;
using System.Configuration;
using System.IO;
using AGI.Parallel.Client;
using AGI.Parallel.Infrastructure;

namespace CodeSamples
    class Program
        static void Main(string[] args)
            // For this example, let's just create the example config file.  In production,
            // you may know beforehand your configuration file or if you want the host
            // process to use the same configuration file the current application is running
            // as you can pass: AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
            string configurationPath = Path.GetTempFileName();
            File.WriteAllText(configurationPath, @"<configuration>
    <add key=""YourKey"" value=""KeyValue"" />

            using (IJobScheduler scheduler = new ClusterJobScheduler("localhost"))
                Job job = scheduler.CreateJob();

                // Pass in the configuration file path to SetConfigurationFile
                // You can also pass the configuration content as a string to SetConfigurationString

                job.AddTask(new ReportsConfigurationFile());

                Console.WriteLine("YourKey: " + job.Tasks[0].Result);
                Console.WriteLine("ConfigurationContent:\n" + job.Tasks[0].StandardOutput);

             * The output of the application should resemble:
             * YourKey: KeyValue
             * ConfigurationContent:
             * <configuration>
             *   <appSettings>
             *     <add key="YourKey" value="KeyValue" />
             *   </appSettings>
             * </configuration>

        class ReportsConfigurationFile : Task
            public override void Execute()
                // Demonstrates how you could use the example configuration content we sent.

                // If you receive "error CS0103: The name 'ConfigurationManager' does not exist in the current context"
                // at this line, add a reference to the System.Configuration assembly to the project.
                this.Result = ConfigurationManager.AppSettings["YourKey"].ToString();

                // Let's just print out the file so that we see that it is actually loaded on the host side.
See Also

STK Scalability 1.4 API for .NET