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

App.config stranger string...

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
7 1447
>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
<?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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Maxim Khesin | last post by:
I want to have a config file with my python proggie, satisfying the following requirements: 1) support key->(value, default) 2) simple and intuitive to read and edit 3) easyly readable into a...
0
by: Ant Corrie | last post by:
I am at a loss as to why this is not working. I am trying to setup a TextWriterTraceListener in my application config file and then execute the app from the network. I get a security exception...
6
by: Kevin Newman | last post by:
I have a situation, where I'd like to dynamically create a function in the global space (window.funcWillGoHere) and have it call a method (or private function) of an instantiated object that it...
1
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; ...
0
by: Manuel Arias | last post by:
Hello everyone I am having a bit of a problem reading a configuration file for an app host via IE. If I make a simple .net app with just a button that calls a function in a class library that...
5
by: Sridhar | last post by:
Hi, I have created a project which contains classes to read the data from the database. This project has an App.Config file which contains the SqlConnection String. when this code is called from...
5
by: Keith | last post by:
Hello all, I have a C# Windows Forms app. It is in namespace App.GUI. It builds to Nav.exe. I have entered an application level setting using the designer. Its type is string, name is "FOO"...
10
by: eagle | last post by:
I have a web.config in my application that contains the connection strings to all my datasources. I want to move these connection strings to another web config up the folder hierarchy so that all...
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.