Changing application level settings in code - How

  • Thread starter Thread starter Robert Dufour
  • Start date Start date
R

Robert Dufour

Its easyb to change user leve settings but how do you change application
level settings in code. Apparently it seems it can't be done.
Duhhh.

Anybody manage a workaround?

Thanks for any help.
Bob
 
I need to try to change those in the application settings section of the
app.config file like in the section that follows. They can be changed via
Notepad but I want to be able to change them via a user UI that is more
friendly which I could do in Vs2003. To change the setting in the
usersetttings section all you have to do is write in code
My.settings.Username = "BOB" if it is a user setting. But this does not work
with settings that are set for application level because Microsoft in its
wisdom ...ha! made these Readonly. Which means that to configure parameters
of an app you need to use an editor and you can no longer make a simple UI
to make it easy for the User to do.

If you make them User level settings then they need to be set each time
someone with a different user name logs in to the machine, which is no good
either, somme settings need to be for the app, some need to be for the
individual user.

The old method of putting the setting in vs2003 files does not permit you to
change them with the 2005 designer, but these could be changed by user in
code, I had a class to do that, but then you have 3 different ways of
storing and maintaining settings which is a lousy patch. Microsoft changed
the way the values are stored in the XML file between 2003 and 2005.They
ever heard of KISS? It means Keep It Simple Stupid! There's also wisdom in
If it ain't broke, don't fix it!

Anyways if someone has some code that allows to change setting in this
section of the app.config I would appreciate a snippet.

<applicationSettings>
<SGIIMSPostesEtPlans2007.My.MySettings>

<setting name="UserLocale" serializeAs="String">

<value>en-US</value>

</setting>

<setting name="AutomaticSenderEmailAddress" serializeAs="String">

<value>[email protected]</value>

</setting>

<setting name="YourCompanyEmailAddress" serializeAs="String">

<value>[email protected]</value>

</setting>

<setting name="YourCompanyName" serializeAs="String">

<value>Company name</value>

</setting>

<setting name="ConnectionString" serializeAs="String">

<value>Provider=SQLOLEDB.1;Data Source=Winxp1;Persist Security
Info=False;Integrated Security=SSPI;Initial Catalog=rmtTel</value>

</setting>

</SGIIMSPostesEtPlans2007.My.MySettings>

</applicationSettings>

</configuration>



Thanks Cor

Bob
 
Back
Top