|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Replace registry data with app.configIs 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. -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com <newscorrespond***@charter.net> wrote in message news:UbNvg.385$8Y2.9@fe03.lga... > > 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,
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="donotre***@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="donotre***@gmail.com" portNumber="465" authenicationMode="SSL" smtpUserName="mygmailaddr***@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="donotre***@rr.com" portNumber="25" authenicationMode="basic" smtpUserName="myem***@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> <newscorrespond***@charter.net> wrote in message Show quote news:UbNvg.385$8Y2.9@fe03.lga... > > 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 |
|||||||||||||||||||||||