Skip to content

Instantly share code, notes, and snippets.

@khalidabuhakmeh
Created March 15, 2013 15:16
Show Gist options
  • Save khalidabuhakmeh/5170577 to your computer and use it in GitHub Desktop.
Save khalidabuhakmeh/5170577 to your computer and use it in GitHub Desktop.
// Had to modify the ScriptCs ScriptExecutor to include System.Configuration
// It works as expected to get the appSettings, but not the natural way
// most devs will be used to with ConfigurationManager.AppSettings, also
// not sure if things like SmtpClient will pickup on it.
using System;
using System.Configuration;
var path = Environment.CurrentDirectory + "\\app.config";
Console.WriteLine(path);
var configMap = new ExeConfigurationFileMap {ExeConfigFilename = path};
var configuration = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
var settings = configuration.AppSettings.Settings;
Console.WriteLine("name from configuration is : {0}", settings["name"].Value);
Console.ReadKey();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment