1. Make a file called <TheAddInName>.xll.config with this in:
<configuration> 
    <appSettings> 
        <add key = "Test" value="Forty-two" /> 
    </appSettings> 
</configuration> 


2. In your project, add a reference to the System.Configuration
assembly.

3. In your library add some function to access the settings:
internal static string GetAppSetting(string key) 
{ 
  object setting = 
System.Configuration.ConfigurationManager.AppSettings[key]; 
  if (setting == null) 
  { 
    return "!! INVALID KEY !!"; 
  } 
  return setting.ToString(); 
} 


4. If you run ExcelDnaPack to pack the add-in into a single file, the .xll.config file will automatically be packed too. At runtime, if a .xll.config file is present, it will be used. Otherwise the packed .config file will be used as the configuration for for the add-in's AppDomain.

Last edited Dec 16, 2013 at 7:27 PM by govert, version 2

Comments

steenreem Apr 29, 2014 at 3:37 PM 
Where do you place the '<TheAddInName>.xll.config' so that it gets packed automatically? Is there something you have to add to your .dna file to get the .config to be included with the pack?