I am writing a Windows Service in VB.Net, and right upfront I need to pass
the path to my config.xml file to the constructor of the class which reads
it. In the old days, App.Path & "\config.xml" would have done nicely. I have
tried using Reflection.Assembly.GetExecutingAssembly.Location but this is
horrible! I can't use the easy Application.Path property because it is a
service not a Forms application.
Is there a simple way to do this, or does anyone have any less than simple
but working code which might give me a clue?
Regards
--Jim. 4 16939
Application.StartupPath
"Jim" <no******@this.address> wrote in message
news:Bg****************@fe2.news.blueyonder.co.uk. .. I am writing a Windows Service in VB.Net, and right upfront I need to pass the path to my config.xml file to the constructor of the class which reads it. In the old days, App.Path & "\config.xml" would have done nicely. I have tried using Reflection.Assembly.GetExecutingAssembly.Location but this is horrible! I can't use the easy Application.Path property because it is a service not a Forms application.
Is there a simple way to do this, or does anyone have any less than simple but working code which might give me a clue?
Regards
--Jim.
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:eV**************@TK2MSFTNGP12.phx.gbl... Application.StartupPath
"Jim" <no******@this.address> wrote in message news:Bg****************@fe2.news.blueyonder.co.uk. ..I am writing a Windows Service in VB.Net, and right upfront I need to pass the path to my config.xml file to the constructor of the class which reads it. In the old days, App.Path & "\config.xml" would have done nicely. I have tried using Reflection.Assembly.GetExecutingAssembly.Location but this is horrible! I can't use the easy Application.Path property because it is a service not a Forms application.
Is there a simple way to do this, or does anyone have any less than simple but working code which might give me a clue?
Regards
--Jim.
----- Original Message -----
From: "Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com>
Newsgroups: microsoft.public.dotnet.languages.vb
Sent: Friday, December 10, 2004 5:48 PM
Subject: Re: App.Path equivalent in VB.Net Windows Service
Application.StartupPath
"Jim" <no******@this.address> wrote in message news:Bg****************@fe2.news.blueyonder.co.uk. ..I am writing a Windows Service in VB.Net, and right upfront I need to pass the path to my config.xml file to the constructor of the class which reads it. In the old days, App.Path & "\config.xml" would have done nicely. I have tried using Reflection.Assembly.GetExecutingAssembly.Location but this is horrible! I can't use the easy Application.Path property because it is a service not a Forms application.
Is there a simple way to do this, or does anyone have any less than simple but working code which might give me a clue?
Regards
--Jim.
Application.StartupPath doesn't work for a Service, only a Forms App (I
think, I can't make it go anyway). HOWEVER I have now found the answer:
System.AppDomain.CurrentDomain.BaseDirectory()Rega rds--Jim.
You are right, I read it too quickly... It's one of those days...
Chris
"Jim" <no******@this.address> wrote in message
news:l_*****************@fe2.news.blueyonder.co.uk ... "Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote in message news:eV**************@TK2MSFTNGP12.phx.gbl... Application.StartupPath
"Jim" <no******@this.address> wrote in message news:Bg****************@fe2.news.blueyonder.co.uk. ..I am writing a Windows Service in VB.Net, and right upfront I need to pass the path to my config.xml file to the constructor of the class which reads it. In the old days, App.Path & "\config.xml" would have done nicely. I have tried using Reflection.Assembly.GetExecutingAssembly.Locati on but this is horrible! I can't use the easy Application.Path property because it is a service not a Forms application.
Is there a simple way to do this, or does anyone have any less than simple but working code which might give me a clue?
Regards
--Jim.
----- Original Message ----- From: "Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> Newsgroups: microsoft.public.dotnet.languages.vb Sent: Friday, December 10, 2004 5:48 PM Subject: Re: App.Path equivalent in VB.Net Windows Service
Application.StartupPath
"Jim" <no******@this.address> wrote in message news:Bg****************@fe2.news.blueyonder.co.uk. ..I am writing a Windows Service in VB.Net, and right upfront I need to pass the path to my config.xml file to the constructor of the class which reads it. In the old days, App.Path & "\config.xml" would have done nicely. I have tried using Reflection.Assembly.GetExecutingAssembly.Locati on but this is horrible! I can't use the easy Application.Path property because it is a service not a Forms application.
Is there a simple way to do this, or does anyone have any less than simple but working code which might give me a clue?
Regards
--Jim.
Application.StartupPath doesn't work for a Service, only a Forms App (I think, I can't make it go anyway). HOWEVER I have now found the answer: System.AppDomain.CurrentDomain.BaseDirectory()Rega rds--Jim.
"Jim" <no******@this.address> schrieb: I am writing a Windows Service in VB.Net, and right upfront I need to pass the path to my config.xml file to the constructor of the class which reads it. In the old days, App.Path & "\config.xml" would have done nicely. I have tried using Reflection.Assembly.GetExecutingAssembly.Location but this is horrible! I can't use the easy Application.Path property because it is a service not a Forms application.
\\\
Imports System.IO
Imports System.Reflection
..
..
..
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetEntryAssembly().Location)
End Function
///
BTW: Use 'System.IO.Path.Combine' to combine paths instead of using '&'.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: |
last post by:
Hi,
I have a Windows Service that uses a referenced dotnet-dll.
In my dll I set some public string to a stringvalue that I
get from reading a xml-file(my config file). It works fine
if I use it...
|
by: bob |
last post by:
I have created a simple Windows service in VB.Net which installs fine
using InstallUtil.exe to install it to, for example "c:\test", or
"c:\Windows\YellowBanana", but if I install it to "c:\Program...
|
by: Laszlo Zsolt Nagy |
last post by:
Sorry, I realized that the import zlib was not executed from my
(working) service.
So here is the question: why can't I use zlib from a win32 service? Is
there any way to make it working?
...
|
by: Gianfranco |
last post by:
Hi everybody,
First of all, sorry for my english if it isn't perfect ;-p
I have an error in an asp.net application.
I have win2003 server, with iis 6. I'm developping with visual studio...
|
by: Jody Gelowitz |
last post by:
We are having an issue in that when trying to read a file that is on Server2
from Server1 (through our ASP.NET project), we receive the error:
Access to the path "\\Server2\MyShare\MyFile.tif" is...
|
by: Zachariah |
last post by:
I created a Windows Service and part of its functionality
is to move a PDF file from a location on the service's
local drive stInPath (C:\PDF\) to a location on another
server stOutPath...
|
by: Vikas Kumar |
last post by:
I have created a windows service
that service downloads updated database after regular intervals
till now i am setting path in app.config where it will download database and
will use it from that...
|
by: Gregor Horvath |
last post by:
Hi,
I have a testservice.py (see below). I installed the Windows-Service
successfully. (via commandlineoption install)
The problem is that it runs only when it is in c:\windows\system32 or in...
|
by: Anil Gupte |
last post by:
I wrote my Windows Service first as a regular Windows Exe because it is
easier to debug. In that I used
AppDir = Application.ExecutablePath.Substring(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$) {
}
...
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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: 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...
| |