473,411 Members | 2,013 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,411 software developers and data experts.

Windows Service startup path for settings

Hi!

I have made quite simple Windows Service using C# 2005. I also made
Setup for it into same solution. When I run Setup, it will be installed
ok into C:\Program Files\<MyCompany>\<MyService>.

Setup is also installing self made default "settings.xml"-file into the
same directory. It contains DataTable for the service how to work, that
service is reading into DataTable-object when it is started. These
settings are not same as <MyService>.exe.config settings.

Now the problem is that Service is trying to find this
"settings.xml"-file of the C:\WINDOWS\System32 instead of C:\Program
Files\<MyCompany>\<MyService-path, when my "settingsHandler"-class
contains declaration...

private const string FILE_PATH = "settings.xml";

....and execution fails. How can I tell to the service it should find
this file of the "Application.StartupPath" ?
--
thanks in advance!

Mika
Aug 7 '08 #1
5 8124
"Mika M" <mi*********************@gmail.comwrote in message
news:Oh****************@TK2MSFTNGP02.phx.gbl...
Hi!

I have made quite simple Windows Service using C# 2005. I also made Setup
for it into same solution. When I run Setup, it will be installed ok into
C:\Program Files\<MyCompany>\<MyService>.

Setup is also installing self made default "settings.xml"-file into the
same directory. It contains DataTable for the service how to work, that
service is reading into DataTable-object when it is started. These
settings are not same as <MyService>.exe.config settings.

Now the problem is that Service is trying to find this "settings.xml"-file
of the C:\WINDOWS\System32 instead of C:\Program
Files\<MyCompany>\<MyService-path, when my "settingsHandler"-class
contains declaration...

private const string FILE_PATH = "settings.xml";
private const string FILE_PATH =
System.AppDomain.CurrentDomain.BaseDirectory +
"settings.xml";

Aug 7 '08 #2
On Aug 7, 9:08*am, Mika M <mika.mahonen_removet...@gmail.comwrote:
Hi!

I have made quite simple Windows Service using C# 2005. I also made
Setup for it into same solution. When I run Setup, it will be installed
ok into C:\Program Files\<MyCompany>\<MyService>.

Setup is also installing self made default "settings.xml"-file into the
same directory. It contains DataTable for the service how to work, that
service is reading into DataTable-object when it is started. These
settings are not same as <MyService>.exe.config settings.

Now the problem is that Service is trying to find this
"settings.xml"-file of the C:\WINDOWS\System32 instead of C:\Program
Files\<MyCompany>\<MyService-path, when my "settingsHandler"-class
contains declaration...

private const string FILE_PATH = "settings.xml";

...and execution fails. How can I tell to the service it should find
this file of the "Application.StartupPath" ?
--
thanks in advance!

Mika
Hi,

System.Reflection.Assembly.GetExecutingAssembly(). Location + "\
\settings.xml";
Aug 7 '08 #3
On Aug 7, 9:21*am, "John Vottero" <JVott...@mvpsi.comwrote:
"Mika M" <mika.mahonen_removet...@gmail.comwrote in message

news:Oh****************@TK2MSFTNGP02.phx.gbl...


Hi!
I have made quite simple Windows Service using C# 2005. I also made Setup
for it into same solution. When I run Setup, it will be installed ok into
C:\Program Files\<MyCompany>\<MyService>.
Setup is also installing self made default "settings.xml"-file into the
same directory. It contains DataTable for the service how to work, that
service is reading into DataTable-object when it is started. These
settings are not same as <MyService>.exe.config settings.
Now the problem is that Service is trying to find this "settings.xml"-file
of the C:\WINDOWS\System32 instead of C:\Program
Files\<MyCompany>\<MyService-path, when my "settingsHandler"-class
contains declaration...
private const string FILE_PATH = "settings.xml";

private const string FILE_PATH =
* * * * * * * * System.AppDomain.CurrentDomain.BaseDirectory +
"settings.xml";- Hide quoted text -

- Show quoted text -
you are missing the \ between the foldername and the file name
Aug 7 '08 #4
"Ignacio Machin ( .NET/ C# MVP )" <ig************@gmail.comwrote in
message
news:b8**********************************@d45g2000 hsc.googlegroups.com...
On Aug 7, 9:21 am, "John Vottero" <JVott...@mvpsi.comwrote:

[snip]
>>
private const string FILE_PATH =
System.AppDomain.CurrentDomain.BaseDirectory +
"settings.xml";- Hide quoted text -

- Show quoted text -

you are missing the \ between the foldername and the file name
No I'm not, BaseDirectory includes the trailing \.

Aug 7 '08 #5
On Aug 7, 2:47*pm, "John Vottero" <JVott...@mvpsi.comwrote:
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mac...@gmail.comwrote in
messagenews:b8**********************************@d 45g2000hsc.googlegroups..com...
On Aug 7, 9:21 am, "John Vottero" <JVott...@mvpsi.comwrote:

[snip]
private const string FILE_PATH =
System.AppDomain.CurrentDomain.BaseDirectory +
"settings.xml";- Hide quoted text -
- Show quoted text -
you are missing the \ between the foldername and the file name

No I'm not, BaseDirectory includes the trailing \.
sorry for the error, you are right.
You have another error though, you can only assign a constant to a
constant string.
Aug 8 '08 #6

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

Similar topics

0
by: nfr | last post by:
There appears to be an interesting shortcoming in .NET's assembly discovery algorithm for private assemblies which must be in the execution directory or below (when specified in a config file). ...
2
by: jmlynn | last post by:
Help! I installed MySQL 4.0.20C and it works if I started it with mysqld --console However, if I do the following: mysqld --install net start MySQL
1
by: Jon | last post by:
Hi there I've written a windows service that works OK, apart fom the fact that if it were to fail during startup, I'm not sure of the best way to handle it. If I let the exception fall thru' from...
2
by: R A | last post by:
Hi, I have a Windows Service C# application. How can I get the full path of the application exe? Thanks, Ronen
4
by: SQLScott | last post by:
My esteemed VB.Net gurus, I posted this question a week or so ago and recieved 1 response that helped me somewhat but really did not solve the problem (but I do appreciate the response). I...
3
by: adasilva | last post by:
I have create a Windows service that uses a timer to access a Web Service. The service is set to start Automatically and its using the local system account. The service also logs events to the...
0
by: niclarke | last post by:
I have created a windows service based on a walkthrough in the MSDN library (ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_radcon/html/e24d8a3d-edc6-485c-b6e0-5672d91fb607.htm - ...
2
by: rqcoder | last post by:
Is there a way to change a Service's startup type somewhere in the .net framework? I've been messing around with the System.ServiceProcess namespace which allows me to start, stop and pause...
1
by: serge calderara | last post by:
Dear all, I have build a windows service whcih read soime remote configuration in an application file. That file path is pass as argument in the satrt parameter of the service. If I start the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.