• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

A C# ConfigurationManager query

Scrag Meister

Super poster
Joined
Mar 17, 2010
Messages
4,073
Likes received
163
Thanks received
38
Location
London and Devon
I have little enough hair left as it is and everything on the net implies this is possible, so before I pull out the little remaining......

I have 2 config files.

1. Standard application.exe.config
2. Separate file which I want to call Mappings.config.

The Standard one works fine.

When I try to OpenExeConfiguration on the Mappings .config, which is copied to the build folder correctly, it seems that the system is adding another .config to the file name,such that the System.Configuration.Configuration object generated by the OpenExe... statement has Mappings.config.config as the file name, and 0 entries in the AppSettings.

All I want to do is open "Mappings.config" read some key value pairs exactly as I already do on the standard one.

Have considered using a straight forward text file, but would prefer this method, if I can get it working.


Any ideas?, thanks.
 
I have little enough hair left as it is and everything on the net implies this is possible, so before I pull out the little remaining......

I have 2 config files.

1. Standard application.exe.config
2. Separate file which I want to call Mappings.config.

The Standard one works fine.

When I try to OpenExeConfiguration on the Mappings .config, which is copied to the build folder correctly, it seems that the system is adding another .config to the file name,such that the System.Configuration.Configuration object generated by the OpenExe... statement has Mappings.config.config as the file name, and 0 entries in the AppSettings.

All I want to do is open "Mappings.config" read some key value pairs exactly as I already do on the standard one.

Have considered using a straight forward text file, but would prefer this method, if I can get it working.


Any ideas?, thanks.


See here c# - OpenExeConfiguration Path Issue - Stack Overflow

edit: and http://stackoverflow.com/questions/513410/open-web-config-from-console-application
 

You must spread some Reputation around before giving it to mudskipper again.

Thanks.

I have come to the conclusion that it is not possible to have 2 "appSettings" config files, so have reverted to having just the one.

1 "connectionStrings" file and 1 "appsettings" file is what seems to be possible.

Did try using the connectionStrings file as the secondary config, but the structure for the items is different and would only confuse users when they edited it.

Oh well, onward and upward, have wasted too much time on this already.

Comma delimited text file anyone? :D
 

Advertisers

Back
Top