Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am developing custom toolbar and buttons for ArcMap 10.1 utilizing VS2010 and ArcObjects SDE 10.1 extensions. I put some application settings in the app.config file and I want to make them available in the runtime. When I execute

private static readonly string appSetting1 = System.Configuration.ConfigurationManager.AppSettings["appSetting1 "];

the value is null.

When I execute

AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

the value is

"C:\Program Files (x86)\ArcGIS\Desktop10.1\bin\ArcMap.exe.Config"

Should I put my application settings is the ArcMap.exe.Config in order make them available to the ArcMap 10.1 custom toolbar or there is another way to do this? Thanks

share|improve this question
1  
There is not a way to reference settings in an app.config for your custom assembly. stackoverflow.com/questions/4889377/… Why do you need these settings in an app.config? Do you expect the user to be changing them or are they more constants? –  Darlene Aug 7 '13 at 22:32
    
I was hoping to use the settings instead of hard-coding values in the .cs files. Things like illegal characters RegEx string; max number selected features allowed, etc. I have to recompile every time those change instead of changing just the app.config settings –  mitaka Aug 8 '13 at 16:12
add comment

1 Answer 1

up vote 2 down vote accepted

If you really need as assembly to have it's own config you directly load it using this .net code.

System.Configuration.ExeConfigurationFileMap fileMap = new System.Configuration.ExeConfigurationFileMap();
fileMap.ExeConfigFilename = "THE PATH TO THE CONFIG";
System.Configuration.Configuration cfg =
System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(fileMap, System.Configuration.ConfigurationUserLevel.None);

string thevalue=cfg.AppSettings.Settings[variable].Value;

http://msdn.microsoft.com/en-us/library/ms134269.aspx

Also you can look at these StackOverflow posts - http://stackoverflow.com/questions/53545/get-the-app-config-of-another-exe http://stackoverflow.com/questions/311253/config-files-for-assemblies-in-gac

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.