Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Replace registry data with app.config

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
newscorrespondent@charter.net - 20 Jul 2006 16:19 GMT
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
Nicholas Paldino [.NET/C# MVP] - 20 Jul 2006 16:26 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> 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
sloan - 20 Jul 2006 16:47 GMT
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="donotreply@donotreply.com"
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="donotreply@gmail.com" portNumber="465"
authenicationMode="SSL" smtpUserName="mygmailaddress@gmail.com"
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="donotreply@rr.com" portNumber="25"
authenicationMode="basic" smtpUserName="myemail@rr.com" 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>

> 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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.