Using config file with Windows Service.

R

Rico

Hello,

I have a Windows Service writting in VB.net 2003. There are some items in
the service that will require certain variables such as Admin Email Address,
smtp server, SQL Server name and instance, database name, things like that.
Is there any way to do this using a config file with a service? If so, is
it implemented the same way as a normal EXE? If not, what is the best
practice to allow an administrator to change these types of things without
having to modify the source code and rebuild?

Any direction would be great!

Thanks!
Rick
 
G

Guest

Rico said:
I have a Windows Service writting in VB.net 2003. There are some
items in the service that will require certain variables such as Admin
Email Address, smtp server, SQL Server name and instance, database
name, things like that. Is there any way to do this using a config
file with a service? If so, is it implemented the same way as a
normal EXE? If not, what is the best practice to allow an
administrator to change these types of things without having to modify
the source code and rebuild?

app.config.
 
R

Rico

I know what it's called and how to use it in an EXE but my question is
1). Why doesn't it show up automatically in my Windows Service project
2). How do I add it to that project
3). How do I use it once it's there (I've always used it with controls,
text boxes, connection objects etc.)

My bad, it's not 2003 I'm using it's 2005.

Rick
 
G

Guest

Rico said:
I know what it's called and how to use it in an EXE but my question is
1). Why doesn't it show up automatically in my Windows Service project

Because not all apps need it :)
2). How do I add it to that project

In the solution explorer, add new item, select application configuration
file.
3). How do I use it once it's there (I've always used it with controls,
text boxes, connection objects etc.)

Add a dll reference to System.Configuration. Then you can access the config
file through System.Configuration.ConfigurationManager.AppSettings
("MyKeyHere").
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top