473,395 Members | 1,658 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,395 software developers and data experts.

App.Config

Hi,

Have a question about an AppSetting's file in VS2005.

Under Assembly \ Properties I got a Settings.settings which contains a
table of name, type, value etc. I also got a App.Config file in the
assembly which mirror the values in the table. When building the app
it generates WindowsApplication1.exe.config which is a copy of
App.Config. However If I change the content of the
WindowsApplication1.exe.config file using notepad, say from
<add key="KEY" value="test" />
to
<add key="KEY" value="demo" />
and re-run the application (without rebuilding it) it does not use the
new value.

I'm using this code to retrive the data;

string s = ConfigurationManager.AppSettings.Get("KEY");

Whats the correct way of using an settings file with .NET 2.0 that a
user can edit manually ? Should I be using other resources and api?

Cheers

Apr 18 '07 #1
10 6178
The app.config file is used when developing the project, and is compiled
with the project to create the appname.exe.config file, which is used by the
app when running. The appname.exe.config file must be in the directory of
the exectuable's AppDomain, which is the directory the exe resides in. It
can be changed manually and will work after the app is deployed.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"RedLars" <Li***********@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
Hi,

Have a question about an AppSetting's file in VS2005.

Under Assembly \ Properties I got a Settings.settings which contains a
table of name, type, value etc. I also got a App.Config file in the
assembly which mirror the values in the table. When building the app
it generates WindowsApplication1.exe.config which is a copy of
App.Config. However If I change the content of the
WindowsApplication1.exe.config file using notepad, say from
<add key="KEY" value="test" />
to
<add key="KEY" value="demo" />
and re-run the application (without rebuilding it) it does not use the
new value.

I'm using this code to retrive the data;

string s = ConfigurationManager.AppSettings.Get("KEY");

Whats the correct way of using an settings file with .NET 2.0 that a
user can edit manually ? Should I be using other resources and api?

Cheers

Apr 18 '07 #2
Thanks for the feedback.

Say I have a solution with one .exe and 3-4 aseemblies and I want one
common config file. How would I go about setting that up?

I mean, in which component do I place the app.Config file so that all
components can access its' information?

Say the the project consists of Demo.exe, common.dll, foo.dll and
bar.dll and they all needs to read config information from one place
(App.config?). All are part of same solution. Sort of confuessed here
as youse might have noticed.

Appreciate any feedback.

On 18 Apr, 13:10, "Kevin Spencer" <unclechut...@nothinks.comwrote:
The app.config file is used when developing the project, and is compiled
with the project to create the appname.exe.config file, which is used by the
app when running. The appname.exe.config file must be in the directory of
the exectuable's AppDomain, which is the directory the exe resides in. It
can be changed manually and will work after the app is deployed.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net
Apr 18 '07 #3
Hi RedLars,

In Visual Studio 2005, you can add Settings to each separate project. If
they exist in the executable Project, the values in the executable Project
will be used. I have done very similar types of projects myself.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"RedLars" <Li***********@gmail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
Thanks for the feedback.

Say I have a solution with one .exe and 3-4 aseemblies and I want one
common config file. How would I go about setting that up?

I mean, in which component do I place the app.Config file so that all
components can access its' information?

Say the the project consists of Demo.exe, common.dll, foo.dll and
bar.dll and they all needs to read config information from one place
(App.config?). All are part of same solution. Sort of confuessed here
as youse might have noticed.

Appreciate any feedback.

On 18 Apr, 13:10, "Kevin Spencer" <unclechut...@nothinks.comwrote:
>The app.config file is used when developing the project, and is compiled
with the project to create the appname.exe.config file, which is used by
the
app when running. The appname.exe.config file must be in the directory of
the exectuable's AppDomain, which is the directory the exe resides in. It
can be changed manually and will work after the app is deployed.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

Apr 18 '07 #4
Thanks for the feedback.

Unfortunately my problem is not coming across right.

Say I create a solution and add four dll projects to the solution. If
I then add different settings to each project (project properties-
>settings) and build the solution I get five libraryConfig.exe.config
files that mirror the individual settings in each project I created.
This is not acceptable for me, I'm looking for just one config file
for all the projects within the solution.

In addition, a requirement of the project is that the config file
should not depend on the .exe of the project to work (Dont want for
instance LibraryCommon.dll to depdent on Library.exe to read the
config file).

So how can I, using .NET and Visual Studio, create and maintain one
config file that all projects within a visual studio solution can
access and alter.

On 18 Apr, 18:43, "Kevin Spencer" <unclechut...@nothinks.comwrote:
Hi RedLars,

In Visual Studio 2005, you can add Settings to each separate project. If
they exist in the executable Project, the values in the executable Project
will be used. I have done very similar types of projects myself.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net
Apr 19 '07 #5
What about creating your own XML file and distributing it with the app.
That way any module can access it using standard .Net classes?
"RedLars" <Li***********@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Thanks for the feedback.

Unfortunately my problem is not coming across right.

Say I create a solution and add four dll projects to the solution. If
I then add different settings to each project (project properties-
>>settings) and build the solution I get five libraryConfig.exe.config
files that mirror the individual settings in each project I created.
This is not acceptable for me, I'm looking for just one config file
for all the projects within the solution.

In addition, a requirement of the project is that the config file
should not depend on the .exe of the project to work (Dont want for
instance LibraryCommon.dll to depdent on Library.exe to read the
config file).

So how can I, using .NET and Visual Studio, create and maintain one
config file that all projects within a visual studio solution can
access and alter.

On 18 Apr, 18:43, "Kevin Spencer" <unclechut...@nothinks.comwrote:
>Hi RedLars,

In Visual Studio 2005, you can add Settings to each separate project. If
they exist in the executable Project, the values in the executable
Project
will be used. I have done very similar types of projects myself.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net
Apr 19 '07 #6
Yeah, I'm definitely considering that. Initally I'd perfer using .NET
(i.e. not re-inventing the wheel) but now I'm not so sure.

On 19 Apr, 22:11, "macleod" <macleod1...@msn.comwrote:
What about creating your own XML file and distributing it with the app.
That way any module can access it using standard .Net classes?"RedLars" <Liverpool1...@gmail.comwrote in message

news:11**********************@l77g2000hsb.googlegr oups.com...

Apr 20 '07 #7
Hi Lars,

Perhaps you want to use the linkedConfiguration Configuration element:

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

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"RedLars" <Li***********@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Thanks for the feedback.

Unfortunately my problem is not coming across right.

Say I create a solution and add four dll projects to the solution. If
I then add different settings to each project (project properties-
>>settings) and build the solution I get five libraryConfig.exe.config
files that mirror the individual settings in each project I created.
This is not acceptable for me, I'm looking for just one config file
for all the projects within the solution.

In addition, a requirement of the project is that the config file
should not depend on the .exe of the project to work (Dont want for
instance LibraryCommon.dll to depdent on Library.exe to read the
config file).

So how can I, using .NET and Visual Studio, create and maintain one
config file that all projects within a visual studio solution can
access and alter.

On 18 Apr, 18:43, "Kevin Spencer" <unclechut...@nothinks.comwrote:
>Hi RedLars,

In Visual Studio 2005, you can add Settings to each separate project. If
they exist in the executable Project, the values in the executable
Project
will be used. I have done very similar types of projects myself.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

Apr 20 '07 #8
Hi RedLars,

<LinkedConfigurationthat Kevin referred is certainly great but that
is specific .NET 3.0. I believe for the time being
"ExeConfigurationFileMap" in conjunction with
"OpenMappedExeConfiguration" can be helpful. Your dll components can
have their own configuration files and Exe application has its own.
You can load each components config settigs when it is first
instantiated. For simplicity you can create a seperate method in each
assembly that will load config settings and you can call this method
whenever module is laoded for the first time in memory.

Regards,
Irfan.

On Apr 20, 3:50 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
Hi Lars,

Perhaps you want to use the linkedConfiguration Configuration element:

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

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

"RedLars" <Liverpool1...@gmail.comwrote in message

news:11**********************@l77g2000hsb.googlegr oups.com...
Thanks for the feedback.
Unfortunately my problem is not coming across right.
Say I create a solution and add four dll projects to the solution. If
I then add different settings to each project (project properties-
>settings) and build the solution I get five libraryConfig.exe.config
files that mirror the individual settings in each project I created.
This is not acceptable for me, I'm looking for just one config file
for all the projects within the solution.
In addition, a requirement of the project is that the config file
should not depend on the .exe of the project to work (Dont want for
instance LibraryCommon.dll to depdent on Library.exe to read the
config file).
So how can I, using .NET and Visual Studio, create and maintain one
config file that all projects within a visual studio solution can
access and alter.
On 18 Apr, 18:43, "Kevin Spencer" <unclechut...@nothinks.comwrote:
Hi RedLars,
In Visual Studio 2005, you can add Settings to each separate project. If
they exist in the executable Project, the values in the executable
Project
will be used. I have done very similar types of projects myself.
--
HTH,
Kevin Spencer
Microsoft MVP
Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

Apr 20 '07 #9
My apologies for making a wrong statement regarding
LinkedConfiguration. I felt sorry when after positng I read this:

"The way for application config file to include another config file,
is a feature we introduced in .Net 2.0. This is called
"linkedConfiguration".

Regards
Irfan.

On Apr 20, 4:25 pm, M Irfan <mohd.ir...@gmail.comwrote:
Hi RedLars,

<LinkedConfigurationthat Kevin referred is certainly great but that
is specific .NET 3.0. I believe for the time being
"ExeConfigurationFileMap" in conjunction with
"OpenMappedExeConfiguration" can be helpful. Your dll components can
have their own configuration files and Exe application has its own.
You can load each components config settigs when it is first
instantiated. For simplicity you can create a seperate method in each
assembly that will load config settings and you can call this method
whenever module is laoded for the first time in memory.

Regards,
Irfan.

On Apr 20, 3:50 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
Hi Lars,
Perhaps you want to use the linkedConfiguration Configuration element:
http://msdn2.microsoft.com/en-us/library/ms404300.aspx
--
HTH,
Kevin Spencer
Microsoft MVP
Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net
"RedLars" <Liverpool1...@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Thanks for the feedback.
Unfortunately my problem is not coming across right.
Say I create a solution and add four dll projects to the solution. If
I then add different settings to each project (project properties-
>>settings) and build the solution I get five libraryConfig.exe.config
files that mirror the individual settings in each project I created.
This is not acceptable for me, I'm looking for just one config file
for all the projects within the solution.
In addition, a requirement of the project is that the config file
should not depend on the .exe of the project to work (Dont want for
instance LibraryCommon.dll to depdent on Library.exe to read the
config file).
So how can I, using .NET and Visual Studio, create and maintain one
config file that all projects within a visual studio solution can
access and alter.
On 18 Apr, 18:43, "Kevin Spencer" <unclechut...@nothinks.comwrote:
>Hi RedLars,
>In Visual Studio 2005, you can add Settings to each separate project. If
>they exist in the executable Project, the values in the executable
>Project
>will be used. I have done very similar types of projects myself.
>--
>HTH,
>Kevin Spencer
>Microsoft MVP
>Printing Components, Email Components,
>FTP Client Classes, Enhanced Data Controls, much more.
>DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

Apr 20 '07 #10
In 2.0, ConfigurationManager class provides for reading from the
App.Config file.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Apr 23 '07 #11

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

Similar topics

13
by: Maxim Khesin | last post by:
I want to have a config file with my python proggie, satisfying the following requirements: 1) support key->(value, default) 2) simple and intuitive to read and edit 3) easyly readable into a...
4
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply*...
3
by: Richard Lewis Haggard | last post by:
I have a test application that is calling an assembly that reads some strings out of a config file. Normally, this assembly supports a web application and the information can be read just fine....
13
by: Khodr | last post by:
Hello, I am using VS.NET 2003 and vb. I build my application MyApp and it generates MyApp.exe.config. So now MyApp.exe reads parameters from MyApp.exe.config. Great and no problem! I need to...
20
by: tomerfiliba | last post by:
hey i've been seeing lots of config-file-readers for python. be it ConfigObj (http://www.voidspace.org.uk/python/configobj.html) or the like. seems like a trend to me. i came to this conclusion...
11
by: TARUN | last post by:
Hello All I need to ask about the configuration file in .NET, There are Two config File 1. Web Config 2. Machine config I understand the the usage of Web config , but not able to understand...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
5
by: mmcd79 | last post by:
I built a VB.net application that makes use of a machine level DB connection string setting, and a user level starting location setting. The machine level setting and the default user based...
10
by: eagle | last post by:
I have a web.config in my application that contains the connection strings to all my datasources. I want to move these connection strings to another web config up the folder hierarchy so that all...
5
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a app that uses several membership/role providers. I can list these Providers with the code: Dim rootWebConfig1 As Configuration rootWebConfig1 =...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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...

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.