VB.NET Application settings


Hey, I just made the switch to VB.NET from VB6.0, and I see that there are properties on every control called Application Settings.  Seems like they are a way to bind properties to a configuration file, to make certain settings persistent, right?

Even back in VB6.0 I was old-school about making my apps persistent, I would use INI files instead of the registry... I'll be darned if I'm going to bury important data in a place where nobody can ever edit it.  Rolled my own little class to save/load all my required INI settings, it served me very well for a long time.

So before I invest a lot of time in learning, implementing, and evaluating Application Settings, does anybody have an opinion, are they worth a darn?  Are the saved somewhere that makes sense, and editable?  Do they have a real advantage over INI files?

Scoring high, hoping to split it among a few good perspectives.  Thanks!
riceman0Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Arthur_WoodCommented:
The .NET equivalent of the OLD INI file, is the app.config file - which is a XML file, that resides in the BIN folder where the application .EXE resides.  The .config file, a template of which is created for you when the project is created by Visual Studio.NET, has a section

<configuration></configuration>  where you can add whatever key value pairs you need to set upi the necessary configuration items for your application.  

look up Config file in the .NET Help system, or check out this page in the online help system:

http://msdn2.microsoft.com/en-us/library/8eyb2ct1.aspx

AW

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
riceman0Author Commented:

Hmm, don't see my .config file.  Your comment raises a question though, when you deploy an app EXE to a new computer, and there is no BIN subfolder, where does the app.config file go, in the local directory?  

Seems complex, though.  Main thrust of my question: does it have the edge over easy-as-pie INI files?  Unless I get a definitive "yes" from someone, not even going to try it, sit this one out like I sat out the inferior registry settings.

riceman0Author Commented:

By the way, I'll spread the points between all useful, persuasive, and/or informed answers, whether "yes" or "no".  
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

amyhxuCommented:
When you deploy the app, the app.config file is in the local directory, such as: C:\Program Files\CompanyName\AppName\app.config.

As you want to hear a "yes" to try it out, I would say "yes". And here's a good example: http://www.code101.com/Code101/DisplayArticle.aspx?cid=3
riceman0Author Commented:

I don't "want" to hear yes, and the links are helpful but not actually what I'm asking for.  I don't want (or have time to) try it out unless someone says something convincing (from personal experience) about how it has improved things for them over traditional config files.  Trying to get the aggregate opinion.  I'm not looking for a reason, I'm just interested in (a) doing things the best way, and (b) NOT wasting time learning things that aren't the best way.  I also recognize there is often a difference between the latest way, and the best way.
rfgkevCommented:
basically, the app.config uses the built in features to do what you're doing with a custom class and ini files. it makes absolutely no difference for windows apps, the only difference for web apps is that IIS does not serve .config files so they are protected in that sense from users.

The real questions are

A) Do you want your code to conform to the current "Best Practice" procedures

B) Do you want to recreate your INI class in .net when there is built in stuff for something very similar already

riceman0Author Commented:

Honestly, no, I don't give a whit what microsoft titles "best practice" in their documentation, except where it coincides with what actually makes sense (which is more often than not).  Going back to my comparison, at one time Microsoft considered putting your settings in the registry the "best practice", and that was just goofy.

I was pleased that it only took me about 30 minutes to convert my interface INIFile class and skeleton INI module to .NET (although I'll probably find better commands for things, and it'll need to be refactored).

I've played around with the My.Settings.  Pretty slick designer (project settings tab), although two drawbacks:

a) I don't like having design buried in the project, rather than represented by code.  We try to write very up-front, reviewable code here, and that interface is harder to describe to a reviewer, and harder for him to verify.  Does the designer put the settings code somewhere that we could inspect?

b) I'm trying to figure out whether XML is indeed as readable and editable as the INI format is. I'm leaning towards no (yeah, I know XML is sexier).

c) still figuring out how it handles defaults; with INI commands you supply a default, so basically you could delete your INI file to restore factory config settings, very nice.
riceman0Author Commented:

By the way thanks for the tidbit about IIS, I do write web apps from time to time.  Those are the things I'm looking for: secular, technical things that I wouldn't discover/realize until I get far down the road with the technology that make me love it or hate it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.