473,387 Members | 1,556 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,387 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 8122
"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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.