App.config stranger string...

T

Tamir Khason

Very strange problem
I have windows service, that using information from inside App.config by
ConfigurationSettings.AppSettings["ConfigPath"] <- Everything is ok here
BUT, once I want to read string such as
<add key="ConfigPath" value="%my_home_dir%\config\file.xml" />
or
<add key="ConfigPath" value="C:\Program
Files\MyApplication\Sinfo\config\file.xml" />
it failed on "Illegal String exception"
Once using THE SAME string from INSIDE service - works file, but from
App.config failed.

Notice1: The same string from App.config works fine from Console Application
Notice2: Tried to save myservice.exe.config in service directory and in
System32 directory as well. The same problem.
Notice3: Other string I can read without problems

What is the problem, as I missing something?
 
M

Marc Scheuner [MVP ADSI]

Very strange problem
Once using THE SAME string from INSIDE service - works file, but from
App.config failed.

Can you show us your WHOLE app.config file???

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
T

Tamir Khason

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- placement of MyApp configuration file-->
<add key="MyAppPath" value="C:\Program
Files\MyApp\ServerDirector\conf\manager.xml" />
<!-- addins to Manager directory in site-->
<add key="ManagerDir" value="manager" />
<!-- number of failures req'd to perform automatic IIS Out-Of-Process Pooled
Applications unload. Set to "0" for "never"-->
<add key="OOPUnload" value="1" />

etc..

--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
 
M

Marc Scheuner [MVP ADSI]

Thanks for the app.config file - don't see anything wrong with it.
I have windows service, that using information from inside App.config by
ConfigurationSettings.AppSettings["ConfigPath"] <- Everything is ok here

I don't quite understand - you *can* read something from the
app.config file, from within your service, at first??

I was just thinking that maybe the service doesn't find the app.config
file, or the ConfigurationSettings object might be NULL, or something
like that..... hmm......

Can you read those settings from a "regular" windows apps??

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
T

Tamir Khason

Thank you for response:
Thanks for the app.config file - don't see anything wrong with it.I don't quite understand - you *can* read something from the
app.config file, from within your service, at first??

--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "


Marc Scheuner said:
Thanks for the app.config file - don't see anything wrong with it.
I have windows service, that using information from inside App.config by
ConfigurationSettings.AppSettings["ConfigPath"] <- Everything is ok here

I don't quite understand - you *can* read something from the
app.config file, from within your service, at first??

I was just thinking that maybe the service doesn't find the app.config
file, or the ConfigurationSettings object might be NULL, or something
like that..... hmm......

Can you read those settings from a "regular" windows apps??

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
K

Kevin Yu [MSFT]

Hi Tamir,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you cannot get string values from the
app.config file in a Windows Service application. If there is any
misunderstanding, please feel free to let me know.

Based on the app.config file you have provided, I cannot see any problem
either. I have also put the app.config file in a Windows Service project,
however, I cannot reproduce the problem. Could you show us the code you're
accessing the configuration setting and in which event the code is?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
K

Kevin Yu [MSFT]

Hi Tamir,

With the code and app.config file, I still cannot reproduce the problem on
my computer. I think this problem might relate with the environment on your
computer and how the windows service was installed onto your machine.
Please also use FileMon to check if the .EXE file has refer to the correct
.config file. FileMon can be downloaded from the following link:

http://www.sysinternals.com/ntw2k/source/filemon.shtml

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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