Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Properties.Settings.Default and Setting Alternate Profiles?

Greetings StackOverflow,

In past projects I've gotten used to using the Settings Designer in Visual Studio to make settings files. This has worked well in the past. In my latest project I have a desire to have multiple version, a.k.a. profiles, of the same Settings class, one with production/default values for all the properties and one with test values.

While in search to see if this is possible I noticed that in the XML for the Settings.settings file there are multiple hints that having multiple setting profiles might be possible. For instance in the Settings.settings file the <SettingsFile> tag has a CurrentProfile attribute which is always set to CurrentProfile="(Default)". Inside of that tag there is an empty tag called <Profile />. Lastly the <Value> tag for each setting has a Profile attribute that usually shows Profile="(Default)".

Now, I've tried looking to what the <Profile /> tag is all about and whether I can use it for something but none of my searches have come up with anything.

Ultimately I want to know whether there is a way to have different profiles of the same Settings class, each with it's own default values, so that I can use it might show up like this in my code:

Properties.Settings defaultSettings = Properties.Settings.Default;
Properties.Settings testSettings = Properties.Settings.Test;

If anyone knows where to find the XML Schema for the settings file or if what I am asking for is possible please let me know.

like image 886
LamdaComplex Avatar asked Nov 19 '25 23:11

LamdaComplex


1 Answers

I use the Enterprise library to set up different configurations with different development environments. It takes a little getting used to, but there's a nice configuration tool that'll read the config files and display all of your app settings. You can create delta files for each environment you plan on working with. I added the Merge Configuration executable into a lib folder within the project and topped it of by adding some Build Events to do the merging upon build so that the files are automatically ready for deployment:

"$(ProjectDir)lib\MergeConfiguration.exe" "$(ProjectDir)web.config" "$(ProjectDir)lib\Delta_Dev.dconfig" "$(ProjectDir)Configurations\web.config-dev.config"
like image 159
Mark Avatar answered Nov 21 '25 13:11

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!