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

Where to put configuration information in a Windows app?

It is really pathetic that I don't know this, but here it is. I have been
writing ASP.Net apps for a while, and all configuration information, such as
the database connection string, goes in a text file called Web.config.
There, it is accessible to the entire app and can be changed without
recompiling anything.

Now I am writing a Windows app (using VB.Net). This type of project does not
have a Web.config file (of course) so where do I put the database connection
strings, so that I don't have to recompile if the DB location changes?

Much obliged,
Geoff.
Jul 21 '05 #1
3 6530
Geoff,
Add a "app.config" to your VS.NET project. When you compile the project it
will be named for the executable. For example myproject.exe has
myproject.exe.config.

Because of the ability to set which version of the runtime should be used,
VS.NET 2003 always replaces the myproject.exe.config in the output folder.

You need to add your config file to your VS.NET project's root folder as
app.config, it needs to be named "app.config" without the quotes. When you
build your project VS.NET (both 2002 & 2003) will copy the app.config file
from the project root to your output folder and name it appropriately
(myproject.exe.config).

Note the format of the app.config & web.config are the same, obviously some
web specific sections do not apply to Windows Forms.

Hope this helps
Jay

"Geoff Pennington" <pe*********@stic2.com> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
It is really pathetic that I don't know this, but here it is. I have been
writing ASP.Net apps for a while, and all configuration information, such as the database connection string, goes in a text file called Web.config.
There, it is accessible to the entire app and can be changed without
recompiling anything.

Now I am writing a Windows app (using VB.Net). This type of project does not have a Web.config file (of course) so where do I put the database connection strings, so that I don't have to recompile if the DB location changes?

Much obliged,
Geoff.

Jul 21 '05 #2
In article <uA**************@TK2MSFTNGP09.phx.gbl>,
Ja********@email.msn.com says...
Add a "app.config" to your VS.NET project. When you compile the project it
will be named for the executable. For example myproject.exe has
myproject.exe.config.
...
Note the format of the app.config & web.config are the same, obviously some
web specific sections do not apply to Windows Forms.


Note also that a third config file exists:

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFI G\machine.config

If you only have one database server and your connection string is
invariant, you may wish to place it there. A local entry in app.config
will override the machine.config entry.

I used this technique so that when I take work home (where the
connection string is different), I don't have to edit a config file.

-- Rick

Jul 21 '05 #3
Thanks to both. I think I'm on the right track now. Jeesh, this stuff can be
maddening to try and find in the "help" files!

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
In article <uA**************@TK2MSFTNGP09.phx.gbl>,
Ja********@email.msn.com says...
Add a "app.config" to your VS.NET project. When you compile the project it will be named for the executable. For example myproject.exe has
myproject.exe.config.
...
Note the format of the app.config & web.config are the same, obviously some web specific sections do not apply to Windows Forms.


Note also that a third config file exists:

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFI G\machine.config

If you only have one database server and your connection string is
invariant, you may wish to place it there. A local entry in app.config
will override the machine.config entry.

I used this technique so that when I take work home (where the
connection string is different), I don't have to edit a config file.

-- Rick

Jul 21 '05 #4

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

Similar topics

0
by: Dean | last post by:
This is a problem in ASP.NET, when I run an application from Visual Studio (2003) when I do a "start without debugging". The asp page uses objects that I have built in 3 other projects,...
0
by: CHRIS | last post by:
Isn't it always the case that as soon as you post, you solve the problem? Apparently, adding an extra "space" to a blank line in my web.config file solved this problem. I would be angry that...
3
by: fred bliss | last post by:
Hi All We have a new server running the latest framework, windows server 2003 & IIS 6.0, and we're getting the following error when we try to load the app in IE. Server Error in...
0
by: VB Programmer | last post by:
I added a rich text editor to my webpage. When I run the form I get this error. Any ideas? Server Error in '/HtmlTest' Application....
0
by: VB Programmer | last post by:
I've been using a Rich Textbox control on my webform. It works great. Doing work on another page then all of a sudden when I run the web app I get this error. Any ideas? Server Error in...
3
by: VB Programmer | last post by:
I am using the free rich text editor control from ExportTechnologies. Every once in a while I get this error (for no apparent reason). Sometimes it happens even when I'm working on a totally...
4
by: scottrm | last post by:
We have two developers, call them A and B, (on Windows XP) developing a number of asp.net web sites on a shared server (Windows 2003). Everything has been ok but recently for no apparent reason...
1
by: Ramanfromoz | last post by:
Hi, Developing a new we application. Everything okay on my local WIN XP PROFESSIONAL, IIS 5.0 running locally. The website is running smoothly. Now, the same code I am copying over to a...
1
by: Dan | last post by:
Hi everyone, I have a web application that was built in .net. I received the source code and the DLL files, compiled the application, and when I run it on IIS, I get the following error. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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,...

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.