By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,995 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,995 IT Pros & Developers. It's quick & easy.

App.config stranger string...

P: n/a
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?

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

Nov 16 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
>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
Nov 16 '05 #2

P: n/a
<?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 "
"Marc Scheuner [MVP ADSI]" <m.********@inova.SPAMBEGONE.ch> wrote in message
news:7j********************************@4ax.com...
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

Nov 16 '05 #3

P: n/a
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
Nov 16 '05 #4

P: n/a
Thank you for response:
Thanks for the app.config file - don't see anything wrong with it.
Me too :) I don't quite understand - you *can* read something from the
app.config file, from within your service, at first??Yes, except the first string Can you read those settings from a "regular" windows apps??Yes


--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Marc Scheuner [MVP ADSI]" <m.********@inova.SPAMBEGONE.ch> wrote in message
news:ka********************************@4ax.com... 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

Nov 16 '05 #5

P: n/a
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."

Nov 16 '05 #6

P: n/a
m_xmlpath = ConfigurationSettings.AppSettings["MyAppPath"];
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:aV**************@cpmsftngxa06.phx.gbl...
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."

Nov 16 '05 #7

P: n/a
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."

Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.