473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Registry or equivalent in .NET ?

Hi,

I've written a small C# application which has toolbars which can be
hidden and repositioned. How should I record the current state of the
toolbars when the program shuts down so that it can be displayed in the
same way next time its run ?

Previously under MFC I would have used the registry to save this
configuration info. Is this still the preferred method in .NET or is
there a better way. I have a vague idea you're supposed to use meta
data, but how would you do this in practice ?

Thanks,
Anthony.

Apr 12 '06 #1
10 1543
I continue to use the Registry for UI element position / size / etc
settings.

I see config files as being much more stable than this: something that
is changed occasionally, and (almost?) never by the program itself.

Meta data is typically compiled into your program, and so is not an
appropriate place to save settings like this (I'm not even sure how
that would work). :-)

Apr 12 '06 #2
I'll throw out my $0.02, but wait for other responses. :) I've got an app
that I'm working on right now. It's gonna sit in the system tray, and have
a number of set-up options, as well as storing the current/last
configuration. I plan on storing the current status in an XML configuration
file. In my little mind, that's the way MS is pushing us. It went from an
INI file (in the Windows 3.x days) to the registry (Win9x), and now's it's
apparently heading back to INI type files. I don't know who makes these
things up, but apparently there's job security in architecting these things.
:)

I look forward to other input in this thread!

Clint

"Anthony" <an******@rocketmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hi,

I've written a small C# application which has toolbars which can be
hidden and repositioned. How should I record the current state of the
toolbars when the program shuts down so that it can be displayed in the
same way next time its run ?

Previously under MFC I would have used the registry to save this
configuration info. Is this still the preferred method in .NET or is
there a better way. I have a vague idea you're supposed to use meta
data, but how would you do this in practice ?

Thanks,
Anthony.

Apr 12 '06 #3
I like the app.config file model. For one thing, it doesn't add to the
System Registry, which may be able to handle a lot of data, but still can
have a tendancy to fill up, slow down, and end up with a lot of orphaned
data in it from uninstalls etc. Besides the capability of fairly easy and
direct editing of the configuration, which is a plus as far as I'm
concerned, the XML format makes it extensible, and it is only loaded when
the app is running, vs. the System Registry, which is fully loaded with all
sorts of data not being used at any given time.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Clint" <no****@nowhere.non> wrote in message
news:ux**************@TK2MSFTNGP03.phx.gbl...
I'll throw out my $0.02, but wait for other responses. :) I've got an app
that I'm working on right now. It's gonna sit in the system tray, and
have a number of set-up options, as well as storing the current/last
configuration. I plan on storing the current status in an XML
configuration file. In my little mind, that's the way MS is pushing us.
It went from an INI file (in the Windows 3.x days) to the registry
(Win9x), and now's it's apparently heading back to INI type files. I
don't know who makes these things up, but apparently there's job security
in architecting these things. :)

I look forward to other input in this thread!

Clint

"Anthony" <an******@rocketmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hi,

I've written a small C# application which has toolbars which can be
hidden and repositioned. How should I record the current state of the
toolbars when the program shuts down so that it can be displayed in the
same way next time its run ?

Previously under MFC I would have used the registry to save this
configuration info. Is this still the preferred method in .NET or is
there a better way. I have a vague idea you're supposed to use meta
data, but how would you do this in practice ?

Thanks,
Anthony.


Apr 12 '06 #4
To my mind....

ini files = "expect that user should be able to tweek the apps settings
manualy". Ie modifing an ini file would not be considered something the
user should not do.

reg = "dont mess with me". Users touching the reg should know the
dangers of doing so and should not complain it there attemps to mess
with your setting result in the application not functioning properly.

Anyway Im very sure lots of people will disagree with me on this point.
So positioning toolbars and turning them on/off = "something a user
should not mess with outside of the mechanisim you app provides to do
so." = reg.

Also reg can be per-user .... This means that eveyr user on the
computer will have there own setting for the toolbars. This is also a
good reason to use the reg for this.
-dm

Apr 12 '06 #5
The .net answer to your question is to modify the config file.

A nice article on this topic is here:
http://odetocode.com/Articles/418.aspx

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Anthony" <an******@rocketmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hi,

I've written a small C# application which has toolbars which can be
hidden and repositioned. How should I record the current state of the
toolbars when the program shuts down so that it can be displayed in the
same way next time its run ?

Previously under MFC I would have used the registry to save this
configuration info. Is this still the preferred method in .NET or is
there a better way. I have a vague idea you're supposed to use meta
data, but how would you do this in practice ?

Thanks,
Anthony.

Apr 12 '06 #6
> ini files = "expect that user should be able to tweek the apps settings
manualy". Ie modifing an ini file would not be considered something the
user should not do.

reg = "dont mess with me". Users touching the reg should know the
dangers of doing so and should not complain it there attemps to mess
with your setting result in the application not functioning properly.
Application configuration files can be encrypted.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

<th*********@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com... To my mind....

ini files = "expect that user should be able to tweek the apps settings
manualy". Ie modifing an ini file would not be considered something the
user should not do.

reg = "dont mess with me". Users touching the reg should know the
dangers of doing so and should not complain it there attemps to mess
with your setting result in the application not functioning properly.

Anyway Im very sure lots of people will disagree with me on this point.
So positioning toolbars and turning them on/off = "something a user
should not mess with outside of the mechanisim you app provides to do
so." = reg.

Also reg can be per-user .... This means that eveyr user on the
computer will have there own setting for the toolbars. This is also a
good reason to use the reg for this.
-dm

Apr 12 '06 #7
> Also reg can be per-user .... This means that eveyr user on the
computer will have there own setting for the toolbars. This is also a
good reason to use the reg for this.
The .Net Platform 2.0 has per-user configuration built in.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

<th*********@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com... To my mind....

ini files = "expect that user should be able to tweek the apps settings
manualy". Ie modifing an ini file would not be considered something the
user should not do.

reg = "dont mess with me". Users touching the reg should know the
dangers of doing so and should not complain it there attemps to mess
with your setting result in the application not functioning properly.

Anyway Im very sure lots of people will disagree with me on this point.
So positioning toolbars and turning them on/off = "something a user
should not mess with outside of the mechanisim you app provides to do
so." = reg.

Also reg can be per-user .... This means that eveyr user on the
computer will have there own setting for the toolbars. This is also a
good reason to use the reg for this.
-dm

Apr 12 '06 #8
That's an awfully long row to hoe just to stop the user from messing
with your window positions and sizes. As well, there may be parts of
the app config that the user _should_ be able to tweak.

I prefer to dump transient stuff like UI settings in the Registry, and
leave app.config for application configuration parameters such as
(encrypted) database connection strings and locations on things on the
network. Stuff that changes rarely but should be tweakable by users or
by administrators. In addition, I don't have the application itself
writing the config file. The config file is version controlled and
rolled out to production, just like the application is.

Apr 12 '06 #9

Kevin Spencer wrote:
Also reg can be per-user .... This means that eveyr user on the
computer will have there own setting for the toolbars. This is also a
good reason to use the reg for this.


The .Net Platform 2.0 has per-user configuration built in.


Yes, thanks I found this after talking to a colleague. For the
information of others, here's how it works:

(1) You go to the solution properties and select the "Settings" tab.
You create settings for each property you want to store.

(2) You read the property's value in your program with a statement
like: Value = Properties.Setting.Defaults.MyProperty;

(3) You save updated settings using the statement:
Properties.Settings.Default.Save().

This will retain user settings between program runs. This works by
storing the settings in an XML file in the following location:

C:\Documents and Settings\UserName\Local Settings\Application
Data\AppName\...

Where UserName is the user currently logged in, and AppName is the name
of the program.

Anthony.

Apr 12 '06 #10
Yes, it's a very cool feature!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Anthony" <an******@rocketmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...

Kevin Spencer wrote:
> Also reg can be per-user .... This means that eveyr user on the
> computer will have there own setting for the toolbars. This is also a
> good reason to use the reg for this.


The .Net Platform 2.0 has per-user configuration built in.


Yes, thanks I found this after talking to a colleague. For the
information of others, here's how it works:

(1) You go to the solution properties and select the "Settings" tab.
You create settings for each property you want to store.

(2) You read the property's value in your program with a statement
like: Value = Properties.Setting.Defaults.MyProperty;

(3) You save updated settings using the statement:
Properties.Settings.Default.Save().

This will retain user settings between program runs. This works by
storing the settings in an XML file in the following location:

C:\Documents and Settings\UserName\Local Settings\Application
Data\AppName\...

Where UserName is the user currently logged in, and AppName is the name
of the program.

Anthony.

Apr 13 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: vincemoon | last post by:
Below is an excerpt from my Registry Log, created by Redmon, showing the process whereby TweakUI added the compressed folder option to the new sub-menu in the right click context menu for open...
3
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to create a registry key, but orphan it from the program that created it? Reason: Create a key, but not associate it with the...
3
by: Aussie Rules | last post by:
Hi, I want to store some data in the registry, however I have not been able to do this, and think my logic maybe flawed. Firstly I try to open the registry and read in any existing values....
6
by: JOSII | last post by:
Getting a string of boolean value into and out of the registry is no problem. Here's the problem: Although you can place an object into the registry and retreive it, I need to place an ArrayList...
4
by: query_me2001 | last post by:
I am trying to find the best way to save data between application sessions. I have an options form that can be used to configure an application. This information needs to be stored so that it can...
14
by: Newbie Coder | last post by:
Hi all, VB.NET 2003 ONLY PLEASE I have a registry key (HKCU\Software\Newbie\SomeKey) of type string which holds an XML string as follows: <root formID="preferencesform" lang="english" ...
20
by: Newbie Coder | last post by:
MFC Application VC++.NET 2003 I have a certain registry key (HKCU\Software\MyKey) that contains between 30 & 64 string values I need to write a '*' to all those 30 - 64 string values under...
0
by: Gary | last post by:
I'm having trouble entering Additional Registry Keys into my Package Solution that will deploy the Access 2007 runtime. (Client machine is running XP with Office 2007 Standard.) The Package...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.