469,306 Members | 1,987 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

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 15983

"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Myo Zaw | last post: by
9 posts views Thread by jsoques | last post: by
3 posts views Thread by Mark | last post: by
2 posts views Thread by Olegus | last post: by
1 post views Thread by Karch | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.