ArcMap Add-in with app.settings not recognizing app.config changes?
I figured out how to configure the addin.
The addin file in ...Documents\ArcGIS\AddIns\Desktop10.0... gets expanded every time ArcMap loads, so the only place that ANY config files embedded in the addin can be edited is in here. I didn't experiment with using registry keys or using a dedicated addin configuration directory as this just seemed overkill.
In the end I used an app.config file (because even if used with a class library, which ignores the config file, it still gets renamed in line with the assembly and automatically included in the addin archive) for my settings. Based on a link provided above I used the following configuration class
...
public AppConfig()
{
try
{
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = this.GetType().Assembly.Location + ".config";
config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
}
catch (Exception)
{
...
}
}
private string getValue(string key)
{
return config.AppSettings.Settings[key].Value;
}
...
To edit the config once the addin is deployed I had to close ArcMap, open the .esriAddIn file with winrar, go to \install and open the config file, edit it, close the editor, and then allow winrar to update the file within the archive. Then reloading ArcMap the change goes in. Annoyingly this is one of the first things I tried but I think I had problems because the editor for the config file was still open when winrar updated the archive.
Borrowing from a similar answer, you might use this in your addin:
string configPath = System.IO.Path.Combine(this.GetType().Assembly.Location,"Config.xml");
The standard .NET configuration file is per application, not per library. This means that when your addin runs within ArcMap process, your configuration settings need to be specified in ArcMap.exe.config which needs to be placed besides ArcMap.exe.
This is of course not always possible in production environment and also violates the isolation of addins, which is one of the reasons addins were introduced in the first place.
You will need to store your settings differently, either in your own config file (as hinted in Kirk's answer) or system registry.
You can monitor changes to your config file in various ways, for example leveraging the FileSystemWatcher class.