Replace registry data with app.config

  • Thread starter Thread starter newscorrespondent
  • Start date Start date
N

newscorrespondent

Is there an MSDN article that I can't find on replacing the registry calls
(Registrykey.GetValue, Registrykey.SetValue) with the calls to get and put
the same data in app.config?

Thanks
Tom
 
Tom,

No, there isn't, since there isn't a one-to-one mapping of how the data
is stored in the registry versus the way it is stored in the app.config
file.

You will have to create your own configuration section handler most
likely which will read the xml in the config file the way that you need to.

It's not a simple search and replace operation. I would recommend
reading some articles on configuration files and the System.Configuration
namespace.

Hope this helps.
 
Tom,

If you check my blog:

spaces.msn.com/sholliday/
2/8/2006 entry

There is a "smtp server settings" project.

Of course, smtp server settings isn't what you're looking for, ~but it has
the code for writing
configuration section handler as Nicholas talks about.

Mine looks like this:

and I use it to create
SmtpServer objects (with some properties)
and put those into a
SmtpServerCollection object.

its basically an xml file to object mapping type system.




<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<configSections>

<section name="EmailSettingsSectionName"
type="GranadaCoder.Email.Settings.EmailSmtpSettingsHandler,GranadaCoder.Emai
l.Settings" />

</configSections>

<EmailSettingsSectionName defaultEmailFrom="(e-mail address removed)"
portNumber="25">

<!--You need to add a reference to
GranadaCoder.Email.Settings.EmailSmtpSettingsHandler.dll since this dll
lives outside this (Presentation) assembly-->

<!--Comments can go here-->

<!--SSL example. Google(gmail)Mail is a good (free) example of this.
Naturally, you need to provide a legitimate username and password-->

<!--Note, with the 2.0 Framework, my tests show that gmail likes port 587-->

<smtpServer enabled="true" smtpServerName="smtp.gmail.com"
defaultEmailFrom="(e-mail address removed)" portNumber="465"
authenicationMode="SSL" smtpUserName="(e-mail address removed)"
smtpUserPassword="mygmailpassword" executeOrder="3"/>

<!--Basic authentication. Passing in a username (and sometimes a password)
are used here.-->

<smtpServer enabled="true" smtpServerName="smtp-server.nc.rr.com"
defaultEmailFrom="(e-mail address removed)" portNumber="25"
authenicationMode="basic" smtpUserName="(e-mail address removed)" executeOrder="2"/>

<!--None authentication. Nothing but the smtp-server name is provided-->

<smtpServer enabled="false" smtpServerName="smtp.noauthenticationneeded.com"
authenicationMode="none" executeOrder="1"/>



</EmailSettingsSectionName>

</configuration>
 
Back
Top