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

Using config file with Windows Service.

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
Mar 17 '07 #1
3 10135
"Rico" <me@you.comwrote in news:2Q_Kh.58627$lY6.22007@edtnps90:
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.
Mar 18 '07 #2
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

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Rico" <me@you.comwrote in news:2Q_Kh.58627$lY6.22007@edtnps90:
>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.

Mar 18 '07 #3
"Rico" <me@you.comwrote in news:_bcLh.60370$lY6.19406@edtnps90:
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.AppSetti ngs
("MyKeyHere").
Mar 18 '07 #4

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

Similar topics

3
by: david | last post by:
I found my web.config file always in lock mode, when I tried to modify it, I ofter got "Can not create web.config" error. I had to reboot my machine, and before I accessed any site I can modify it....
1
by: Troy Murphy | last post by:
I seem to remember using a walkthru in the early beta that demonstrated how to create a Windows Service that would monitor events in a folder. Can someone please direct me to an example of doing...
2
by: Bill | last post by:
I've created a windows service in C#, but I'm having trouble reading <appSettings> from a app.config file. I can read <appSettings> just fine from a normal C# windows app, so there must be some...
12
by: Charlie | last post by:
Hi: My host will not allow me use a trusted connection or make registry setting, so I'm stuck trying find a way to hide connection string which will be stored in web.config file. If I encrypt...
1
by: Jarred | last post by:
Howdy All, I've been having a bit of a problem that I can't seem to get a grip on at the moment and I'm hoping someone may be able to give me a quick hand :) What I have is a Webservice that...
4
by: PeterW | last post by:
I have a Windows service that needs to get some values from a config file. I place the config file for the service in the System32 directory. I do not get the values using the usual...
1
by: herbert | last post by:
In VS.2005 a Windows Service can have an app.config file. A class library can also have an app.config file. Now if my Windows Services uses three class libraries, each of it coming with its own...
1
by: bmaheswar | last post by:
Hi, I have a windows service. it is developed using .Net Framework 1.0. When i try to run that service using CLR PRofile 1.0. Profiler Throws error as show below. See the end of this message...
3
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I created a .settings file and added some values. All values are user set defined. When i load my windows service i can read from the .config file. But, i can set a value and save to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.