Can anyone tell me the preferred method for writing and
retrieving persistent information using .Net.
Specifically, I am referring to information that you used
to see in registry keys or .ini files like the name of a
database or connection string.
I have read several articles indicating that .config files
are now used, but I am confused because they are read-
only. If I want to write information from within the
application (When a user makes a selection) to a
persistent location so that I can retrieve that
information the next time the application is run, what
method do I use?
Any help is much appreciated. 8 4506
You can use XMLDom to work with the config file..or u can go for making your own xml configuration files which stores the user preference, coz the big boyz says that, it is not advisable to store user preference in app.config file..
Regards.
NetPointer
"Steve" <ma******@yahoo .com> wrote in news:04ad01c399 b0$5096f4b0
$a*******@phx.g bl: Can anyone tell me the preferred method for writing and retrieving persistent information using .Net. Specifically, I am referring to information that you used to see in registry keys or .ini files like the name of a database or connection string.
I have read several articles indicating that .config files are now used, but I am confused because they are read- only. If I want to write information from within the application (When a user makes a selection) to a persistent location so that I can retrieve that information the next time the application is run, what method do I use?
Any help is much appreciated.
app.config:
<appSettings>
<add key="a" value="someSett ing" />
</appSettings>
cs file:
using System.Configur ation;
string a = ConfigurationSe ttings.AppSetti ngs["someSettin g"];
if(a==null)
throw new ConfigurationEx eception("a needs to be configured");
--
best regards
Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS http://www.kema.at
"Steve" <ma******@yahoo .com> wrote in news:04ad01c399 b0$5096f4b0
$a*******@phx.g bl: Can anyone tell me the preferred method for writing and retrieving persistent information using .Net. Specifically, I am referring to information that you used to see in registry keys or .ini files like the name of a database or connection string.
I have read several articles indicating that .config files are now used, but I am confused because they are read- only. If I want to write information from within the application (When a user makes a selection) to a persistent location so that I can retrieve that information the next time the application is run, what method do I use?
Any help is much appreciated.
addendum:
when you'll want to save some settings you will have to overwrite the
config file from your code.
or you'll just use your own xml files.
if those settings are per-user better store them in xml files in the
user/ApplicationData directory.
--
best regards
Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS http://www.kema.at
On MSDN Microsoft has an Application Block called Application Configuration
Application Block, or something to that effect. http://msdn.microsoft.com/ .
That might help you out.
-mike
MVP
"Steve" <ma******@yahoo .com> wrote in message
news:04******** *************** *****@phx.gbl.. . Can anyone tell me the preferred method for writing and retrieving persistent information using .Net. Specifically, I am referring to information that you used to see in registry keys or .ini files like the name of a database or connection string.
I have read several articles indicating that .config files are now used, but I am confused because they are read- only. If I want to write information from within the application (When a user makes a selection) to a persistent location so that I can retrieve that information the next time the application is run, what method do I use?
Any help is much appreciated.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Are you looking for the C# equivalent of Java Preferences API (or
previously java.util.Prope rties)? I would look at
System.IO.Isola tedStorage if I were you :)
Steve wrote:
| Can anyone tell me the preferred method for writing and
| retrieving persistent information using .Net.
- --
Ray Hsieh (Djajadinata)
ray underscore usenet at yahoo dot com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQE/m/y8wEwccQ4rWPgRA uJwAJ90EPmIlmZ1 PuM3bGO37U3QVML 5CACghJ0u
x+zmc03vLZg+F/2MJG7bvrI=
=G+xh
-----END PGP SIGNATURE-----
> | Can anyone tell me the preferred method for writing and | retrieving persistent information using .Net.
The most basic conceptual way of doing this is in one page:
string myPersistantInf ormation = "Are you talking to me?";
Session[ "mySessionValue 1" ] = myPersistantInf ormation;
You can go from page to page in your application session and from any page:
string myPersistantInf ormationXYZ = Session[ "mySessionValue 1"];
myPersistantInf ormation can be any type of data including a DataSet. Of
course theres somewhat more to State Management. Here are some helpful
links:
Introduction to Web Forms State Management: http://msdn.microsoft.com/library/de...Management.asp
State Management Recommendations " http://msdn.microsoft.com/library/de...tateoption.asp
A lot of this goes hand in hand with the type of data access method you
pick. If you really want to get into it here's a start:
Recommendations for Data Access Strategies: http://msdn.microsoft.com/library/de...ngdatasets.asp
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Steve was asking about something equivalent to the Windows Registry or
..ini files, which are persistent beyond the lifetime of an application.
Sessions are hardly persistent in this regard--even Application
information are limited by the lifetime of the web application.
Database is persistent, although I doubt that's what he meant. You don't
really put connection strings in a database, eh. That'd be a catch22! ;)
Empire City wrote:
<snipped>
- --
Ray Hsieh (Djajadinata)
ray underscore usenet at yahoo dot com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQE/nOamwEwccQ4rWPg RAlheAJwJjVf4dT KSFekEu8ZcEPnpQ sFc8wCfbQV9
lYdGPLB92+vBI5o 2vG8c3zM=
=Djmq
-----END PGP SIGNATURE-----
"Steve" <ma******@yahoo .com> wrote in message news:<04******* *************** ******@phx.gbl> ... Can anyone tell me the preferred method for writing and retrieving persistent information using .Net. Specifically, I am referring to information that you used to see in registry keys or .ini files like the name of a database or connection string.
I have read several articles indicating that .config files are now used, but I am confused because they are read- only. If I want to write information from within the application (When a user makes a selection) to a persistent location so that I can retrieve that information the next time the application is run, what method do I use?
Any help is much appreciated.
Steve, you have a couple of options. First, you can still use the
registry (it hasn't gone away). There are .NET classes for working
with the registry that make it a valid .NET option and a simple one to
implement. app.config is another option (as this is the one our team
uses most often). As another poster pointed out you can use the XMLDom
classes to write to the app.config to get at what you want.
The third option may be your best bet. Create a new DataSet object and
populate it (by SQL query or manually adding rows dynamicly with code)
then call the DataSet's .WriteXml method to persist the object to XML.
You can then create a new DataSet object and call it's .ReadXml method
to restore your persisted data. This approach is flexible because the
end result is XML serialized instance of your data. Unlike app.config
and the registry it isn't bound to a certin location or system
resource. If you wanted you could create a web service to
store/retrieve the object without having a file system.
You could build you own system to handle this, but it's nice to
leverge what's built in for you. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul Rubin |
last post by:
I've had this recurring half-baked desire for long enough that I
thought I'd post about it, even though I don't have any concrete
proposals and the whole idea is fraught with hazards.
Basically I wish there was a way to have persistent in-memory objects
in a Python app, maybe a multi-process one. So you could have a
persistent dictionary d, and if you say
d = Frob(foo=9, bar=23)
that creates a Frob instance and stores it in d. Then if...
|
by: Peter Foti |
last post by:
Simple question... which is better to use for defining font sizes and why?
px and em seem to be the leading candidates. I know what the general answer
is going to be, but I'm hoping to ultimately get some good real world
examples.
Fire away! :)
Regards,
Peter Foti
|
by: Sidd |
last post by:
Hi,
I tried finding and example of multithreaded client-serve program in
python. Can any one please tell me how to write a multithreaded
client-server programn in python such that
1.It can handle multiple connections
2.It uses actual threads and not select() or some other function
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: Keith G. Murphy |
last post by:
I'm trying to get a feel for what most people are doing or consider best
practice.
Given a mod_perl application talking to a PostgreSQL database on the
same host, where different users are logging onto the web server using
LDAP for authentication, do most people
1) have the web server connecting to the database using its own user
account (possibly through ident), and controlling access to different
database entities strictly through...
| |
by: Marc Gravell |
last post by:
Kind of an open question on best-practice for smart-client design. I'd
really appreciate anyones views (preferably with reasoning, but I'll take
what I get...). Or if anybody has any useful links on the subject? (and yes,
I have already googled it at length, but still no strong decision)
=============
After a long stint of pure-desktop / pure-server applications, I'm currently
working on a number of smart-client projects in C# using...
|
by: Ren |
last post by:
Hi All,
I'm still rather new at vb.net and would like to know the proper way to access
private varibables in a class. Do I access the variable directly or do I use
the public property?
public class MyClass
private _variableName as integer
public property VariableName as integer
|
by: mirandacascade |
last post by:
Assume the following:
1) multi-user environment
2) when user opens app, want to run some code that retrieves some
information specific to the user...retrieving this information is
somewhat i/o intensive, so would prefer to retrieve the info once at
the beginning of the session, and have the data persist for the
session
3) several forms in the app need to reference the information
retrieved in #2 (the information specific to the user)
4)...
|
by: Frank Millman |
last post by:
Hi all
This is not strictly a Python question, but as I am writing in Python,
and as I know there are some XML gurus on this list, I hope it is
appropriate here.
XML-schemas are used to define the structure of an xml document, and
to validate that a particular document conforms to the schema. They
can also be used to transform the document, by filling in missing
attributes with default values.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |