473,804 Members | 3,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

App.Config

Hi,

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

Under Assembly \ Properties I got a Settings.settin gs 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 WindowsApplicat ion1.exe.config which is a copy of
App.Config. However If I change the content of the
WindowsApplicat ion1.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 = ConfigurationMa nager.AppSettin gs.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 6229
The app.config file is used when developing the project, and is compiled
with the project to create the appname.exe.con fig file, which is used by the
app when running. The appname.exe.con fig 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.goo glegroups.com.. .
Hi,

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

Under Assembly \ Properties I got a Settings.settin gs 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 WindowsApplicat ion1.exe.config which is a copy of
App.Config. However If I change the content of the
WindowsApplicat ion1.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 = ConfigurationMa nager.AppSettin gs.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...@n othinks.comwrot e:
The app.config file is used when developing the project, and is compiled
with the project to create the appname.exe.con fig file, which is used by the
app when running. The appname.exe.con fig 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.goo glegroups.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...@n othinks.comwrot e:
>The app.config file is used when developing the project, and is compiled
with the project to create the appname.exe.con fig file, which is used by
the
app when running. The appname.exe.con fig 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.e xe.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.d ll 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...@n othinks.comwrot e:
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.goo glegroups.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.e xe.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.d ll 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...@n othinks.comwrot e:
>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...@ms n.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?"RedLar s" <Liverpool1...@ gmail.comwrote in message

news:11******** **************@ l77g2000hsb.goo glegroups.com.. .

Apr 20 '07 #7
Hi Lars,

Perhaps you want to use the linkedConfigura tion 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.goo glegroups.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.e xe.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.d ll 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...@n othinks.comwrot e:
>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,

<LinkedConfigur ationthat Kevin referred is certainly great but that
is specific .NET 3.0. I believe for the time being
"ExeConfigurati onFileMap" in conjunction with
"OpenMappedExeC onfiguration" 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...@n othinks.comwrot e:
Hi Lars,

Perhaps you want to use the linkedConfigura tion 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.goo glegroups.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.e xe.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.d ll 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...@n othinks.comwrot e:
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
LinkedConfigura tion. 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
"linkedConfigur ation".

Regards
Irfan.

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

<LinkedConfigur ationthat Kevin referred is certainly great but that
is specific .NET 3.0. I believe for the time being
"ExeConfigurati onFileMap" in conjunction with
"OpenMappedExeC onfiguration" 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...@n othinks.comwrot e:
Hi Lars,
Perhaps you want to use the linkedConfigura tion 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.goo glegroups.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.e xe.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.d ll 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...@n othinks.comwrot e:
>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

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

Similar topics

13
3025
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 python datastructure (a dictionary?) 4) not requiring any heavy libraries needed (I am distributing my proggie as a py2exe executable and do not want to bloat the size) can you guys suggest some format for this? thanks, max
4
3831
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* access config files. This is version 3, which is a big overhaul. It extends ConfigObj to reading config files with sections and various other simplifications. I find ConfigObj extremely easy to use and use it for reading config files and data...
3
3821
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. Then I created a C# test application and ran the function. The function fails because the configuration read is failing to find a key. I created an application config and copied the keys over to the app config file but the app is still failing to...
13
507
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 run the same program but with different configuration data. So I made a copy of MyApp.exe and MyApp.exe.config to put them in another folder and renamed the copy to MyApp2.exe and MyApp2.exe.config respectively. I ran it but it did not read from...
20
2630
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 a long time ago: YOU DON'T NEED CONFIG FILES FOR PYTHON. why re-invent stuff and parse text by yourself, why the interpreter can do it for you? and anyway, i find this a very ugly format:...
11
3454
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 the usage of Machine config. I read in the article that you can also write your database connection string in Machine Config
12
13439
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 file was built by draging tables from the Data Sources pane. Auto-generated code created the files associated wtih the XSD file (xss,
5
7870
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 setting is of course stored in the app.exe.config file located in the same directory as the exe. Upon closing the form, I save the user setting which then creates a user.config file in the appdata directory in my profile. This is all well and good....
10
2064
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 my apps can use the same connection strings. That is supposed to be how it's done, no? Instead of the web.config being in c:\inetpub\wwwroot\myApp\web.config, I have it in c:\inetpub\wwwroot\web.config. However, I get an "Object reference not...
5
2864
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 = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) Dim section As New MembershipSection section = rootWebConfig1.GetSection("system.web/membership")
0
9707
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, 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...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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,...
0
10082
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
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...
0
5525
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...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
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...

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.