You want to set the host configuration file.


To set the configuration file, call SetConfigurationFile and pass the path of the configuration file.

C#  Copy imageCopy
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.


The configuration file for the application domain of host executing a task can be changed. For example, an application domain should be configured with a modified configuration file if it requires specific assembly search rules or custom configuration data.

See Also