window service cannot find initial. file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Now that I have placed my class to be called as a service, the service does not know where the XML
file for intialization ( deserilaization ) is.

In my project I dropped the xml file in the bin directory. When I create and run the service I get my message that the file did not exist ( relative path
private string myXMLiniFile="qccomboini.xml";

My first call into the object tests for the fil
if (File.Exists(this.myXMLiniFile)==true

qcIniXML = (qccomboini.defaults)fw.si....

els

retVal="qcMoverConnectionAndZipInitializer initialization file missing " + this.myXMLiniFile

I found another location where the EXE was dropped after creating the service but I get the same error

1.) How do I detect the environment of the service, - > which should answer where my XML file should be placed..
unless you have better suggestions .. Thank
 
Hi,

Thanks for posting.

When we start the Windows Service, the current working directory is the
System32 folder. We may use the following to determine the directory that
holds the Windows Service EXE file:

string dir =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssem
bly().Location);

Then we can append the string with the file name:

myXMLiniFile = dir + @"\qccomboini.xml";

I hope this helps.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hello Andrew,

Thanks for your quick response. I am glad to be of assistance. If you have
any concerns or new findings regarding this issue, please feel free to post
here.

Have a nice day!

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top