Ooooops,
I gave you a wrong snippet .....
Place right at the top of your OnStart() method of your Service main the
following code:
// Define working directory (For a service, this is set to System dir by
default...)
Process pc = Process.GetCurrentProcess();
Directory.SetCurrentDirectory
(pc.MainModule.FileName.Substring(0,pc.MainModule. FileName.LastIndexOf(@"\")
));
This will define the working directory of your service as being the location
where the exe file of the Service is stored.
This assume that the dll launched are in the same directory or known by the
normal ". NET probing".
Just try to place the snippet code I gave you to your OnStart()... and let
me know.
José
<hakan_dont_spam_me@go_away_spam_home.se> wrote in message
news:09****************************@phx.gbl...
Thanks for your reply José,
my problem is that I don´t want to configure my service. I
want to configure my referenced dll. In other words. I
want my service + referenced dll´s to know that they are
executed in the MyService.exe´s directory.
MyService
MyServiceCode
ReferenceToDotNetDll
Dll reads xml-file and set values. XML-file placed in
same directory as the MyService.exe
Is this what you have explained to me? In that case can
you please post som more detailed codesnippets?
//hakan
-----Original Message-----
You can define the working directory of your Service in
the OnStart() methodby doing the following:
// Prepare our remoting server by reading configuration
in the config file.
RemotingConfiguration.Configure
(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
<hakan_dont_spam_me@go_away_spam_home.se> wrote in message
news:06****************************@phx.gbl...
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 in a vb-form. But since Windows Services ?
executes? in windows\system32 I can´t locate my xml-
config-file.
I don´t want to set different "compiling-statements" such
as :
#IF CONFIG = "service2" then
xmlPath = "c:\kklk\service2"
#ELSEIF CONFIG="service3" then
xmlPath = "c:\kklk\service3"
#END IF
I want to return the location of the directory where my
service is. Not the "running" location of the service
("windows\system32"). Everything I try returns
c:\windows\system32
Is there some way of doing the following??
--- myClass.dll
Public ReadOnly strPathName As String = GetPath("path1")
Private Function GetPath(ByVal strValue As String) As
String
Dim oConf As New mmmmXML.XMLConfigurator
(Environment.CurrentDirectory().ToString
& "/XMLConfigurator.xml") '<== get the directory of where
the dll and service-code resides. This doesn´t work
Dim strPath As String
strPath = oConf.GetXPathValue("/mmmmCONFIG/mmmmPATH
[@name='" & strValue & "']/@path")
Return strPath
End Function
--------------------
hmmm.. hope someone will understand my problem
//hakan
.