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

Windows Service and ConfigurationManager

hi,
i don't know why i can't access to app.config file in my windows
service application. it worked fine in win32 application. i already tested
with the same situation and sceniro but, in my service, the call through
configurationmanager (
configurationmanager.appsettings["myName"].tostring() ) showed me null
reference exception. any idea about that? this is my app.config file data
<configuration>
<appSettings><add key="myName" value="Myo Zaw" /></appSettings>
</configuration>

thanks again,
myo zaw
Dec 1 '05 #1
10 16392

"Myo Zaw" <in********@hotmail.com> wrote in message
news:Os**************@tk2msftngp13.phx.gbl...
hi,
i don't know why i can't access to app.config file in my windows
service application. it worked fine in win32 application. i already tested
with the same situation and sceniro but, in my service, the call through
configurationmanager (
configurationmanager.appsettings["myName"].tostring() ) showed me null
reference exception. any idea about that? this is my app.config file data
<configuration>
<appSettings><add key="myName" value="Myo Zaw" /></appSettings>
</configuration>

thanks again,
myo zaw


Make sure your config files resides in the same folder as your Service .exe
file.

Willy.
Dec 1 '05 #2

no,
still didn't work out.

myo zaw
Dec 1 '05 #3
Make sure that the deployed name of the app.config file (which should be
visible "in your project" in Solution Explorer. turns out to be the same as
the built EXE assembly name plus ".config".

Ensure that your project has a reference to the System.Configuration.dll
(it's not there by default).

Otherwise, you've got a syntax error, but from your post it doesn't look
like that's the issue.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Myo Zaw" wrote:

no,
still didn't work out.

myo zaw

Dec 1 '05 #4

sorry,
i misunderstood. it has to be with it's service.exe.config. not
app.config. right?

thanks a lot,
myo zaw

Dec 1 '05 #5
Hi,

It does works fine, my bet is that the filename is incorrect or is not in
the expected location

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Myo Zaw" <in********@hotmail.com> wrote in message
news:Os**************@tk2msftngp13.phx.gbl...
hi,
i don't know why i can't access to app.config file in my windows
service application. it worked fine in win32 application. i already tested
with the same situation and sceniro but, in my service, the call through
configurationmanager (
configurationmanager.appsettings["myName"].tostring() ) showed me null
reference exception. any idea about that? this is my app.config file data
<configuration>
<appSettings><add key="myName" value="Myo Zaw" /></appSettings>
</configuration>

thanks again,
myo zaw

Dec 1 '05 #6

"Myo Zaw" <my****@gmail.com> wrote in message
news:0E**********************************@microsof t.com...

sorry,
i misunderstood. it has to be with it's service.exe.config. not
app.config. right?

thanks a lot,
myo zaw


Say your service executable is called MyService.exe, then forcibly your
config file should be named MyService.exe.config. Both should be in the same
folder.

Willy.
Dec 1 '05 #7

yes,
at first, after i built my service, i copied its exe file to a new
location and install it. didn't work out. but, regarding to willy's
suggestion i copied my app.config file to that location. the same error.
then, i copied my service exe's config to that location and test it.
eventually, work out. thanks so much.

myo zaw

Dec 1 '05 #8

yes,
as you said so willy. thanks so much.

myo zaw

Dec 1 '05 #9
Hi,

Just ot point out, a win service cannot just be copied, it needs to be
installed, let me know if you need to know how
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Myo Zaw" <my****@gmail.com> wrote in message
news:00**********************************@microsof t.com...

yes,
at first, after i built my service, i copied its exe file to a new
location and install it. didn't work out. but, regarding to willy's
suggestion i copied my app.config file to that location. the same error.
then, i copied my service exe's config to that location and test it.
eventually, work out. thanks so much.

myo zaw

Dec 1 '05 #10

hey,
appreciate any kind of help. thanks.

myo zaw

Dec 1 '05 #11

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

Similar topics

3
by: Myo Zaw | last post by:
hi, i have a windows service that check to the external web site httpwebresponse and save the result into log text file. and, my problem is when i shut down my system, i also would like to save...
9
by: jsoques | last post by:
Hello, I created a Web Service using .Net 2.0 that has a function that returns a DataTable. I can test the function from the web page when I access the .asmx from a browser on localhost and it...
2
by: Steven | last post by:
I have a service process that contains two services but only one of them ever works properly. The background is I have two classes which are Individual() and Mass() in the main service class and...
3
by: Mark | last post by:
I am trying to read the appsettings section of a configuration file using the ConfigurationManager object (ASP.NET application) with the following three lines but for some reason the...
2
by: Olegus | last post by:
I have Windows service MyService, that reads some settings from MyService.exe.config file via ConfigurationManager.AppSettings. I tried to write small WinForm frontend app(called it Manager.exe)...
1
by: Karch | last post by:
I am writing a WCF Service using MSMQ hosted in a Windows Service on Windows XP. All the required components are installed (.NET3, MSMQ, etc). For some reason my service tries to start and then...
3
by: Rico | last post by:
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...
0
by: bvanderzanden | last post by:
I'm having a problem dynamically setting the url for the web service used in a dll. When I reference a web service it sets it to dynamic and creates a setting for the url. I have modified the url...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.