473,405 Members | 2,344 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,405 software developers and data experts.

Using appSettings

Bob
Hello,

I have a console app and would like it to pick up some settings from the
application config file....

Can anybody give me the basic rundown on the simplest way to achieve this...
the MSDN stuff for this is really quite vague and does not seem to work when
I do it the MS way in my code.

Anyway, say I have my app.exe.config file with a setting called DebugMode
and a value of "true". No matter how I use the system.configuration methods
I can't retrieve the value...

For starters I need to know... do I create the app.exe.config file in the
bin folder (where file keeps getting deleted) or in same folder as my
solution (if here, should it be called app.config)?

Anybody care to enlighten me?

Cheers
Nov 20 '05 #1
2 1329
Configuration files need to be in the same folder as the EXE and have the
same name with ".config" appended. For example is your EXE is
c:\MyApp\MyApp.exe then the config file needs to be
c:\MyApp\MyApp.exe.config.

App.config is a Visual Studio shortcut you can use. When you ask VS to add
an application configuration file to your project it will add the file
called App.config and put it in the same folder as your source code. When
you build your project, VS will copy App.config to the build folder and
rename it as required.

Hope this helps.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada

"Bob" <1@2.3> wrote in message news:Ou**************@TK2MSFTNGP11.phx.gbl...
Hello,

I have a console app and would like it to pick up some settings from the
application config file....

Can anybody give me the basic rundown on the simplest way to achieve this... the MSDN stuff for this is really quite vague and does not seem to work when I do it the MS way in my code.

Anyway, say I have my app.exe.config file with a setting called DebugMode
and a value of "true". No matter how I use the system.configuration methods I can't retrieve the value...

For starters I need to know... do I create the app.exe.config file in the
bin folder (where file keeps getting deleted) or in same folder as my
solution (if here, should it be called app.config)?

Anybody care to enlighten me?

Cheers

Nov 20 '05 #2
Just another comment, when you add the application configuration file ensure you don't tamper with the file name, otherwise the file won't be copied to the compile output of the project (bin directory).
Nov 20 '05 #3

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

Similar topics

0
by: Shawn Melton | last post by:
#Region "Imports Imports ADSSECURITYLi Imports System.Diagnostic Imports Scriptin Imports ActiveD Imports System.DirectoryService Imports System.Configuration.ConfigurationSetting Imports...
17
by: Davíð Þórisson | last post by:
now in my web I have some global variables to be used in many different subpages, in the old ASP I simply loaded a variables.asp file into memory using the eval() function. Now I'd like to use XML...
12
by: John M | last post by:
Hello, On Microsoft Visual Studio .NET 2003, I want to use some global elements, that can be used in each one of my pages. i.e I put a oleDBConnection on global.asax.vb How can I use it...
13
by: JIM.H. | last post by:
Hello, I have the following lines to read connection string from web.config; string cStr = ConfigurationSettings.AppSettings; SqlConnection sqlConn = new SqlConnection(cStr);...
4
by: Sai | last post by:
Hi, I am using VSTO 2005 Beta for building an excel application. I added application configuration file to the project (app.config) and it has the following section in it. <configuration>...
12
by: shawnn | last post by:
Hello, By default, when you create an App.config file it gets named as MyApp.exe.config after build. I don't like this name and would rather have the file named MyApp.config, the .exe.config...
3
by: Ashish | last post by:
I am writing a business layer component and want to store some configuration parameters for it, i dont want to use web.config of the web application that would use this business layer because of...
7
by: moondaddy | last post by:
I'm running a wpf windows app and want to add the appSettings element to the config file. when I do, the app wont start up and I get the following error: {"The type initializer for...
4
Frinavale
by: Frinavale | last post by:
Introduction Many .NET applications will require an email be sent out for various reasons. This article will give a quick examples on how to send an email using VB.NET. The examples given can...
2
by: daljeet30 | last post by:
Hi i m daljeet singh. i m using Visual C#.net 2005 but i have facing problem Following code i used in app.config file <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> ...
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: 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...
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
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...
0
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,...
0
isladogs
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...

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.