Junior_Developer
asked on
Windows service with app.config file
Hi Experts,
In my config file i have source path and destination path...
i am using these paths in my windows service to rename files...
if i use the map drives then it works but when i use 90.xxx.xxx.xx\somepath then it doesnt work.
Note i have tried to change user account to the accout that has access to the above path...
Need assistance to create a log file so i would now what error is happening and how do i resolve this. below is my config file and code from windows service to rename the destination files
CONFIG FILE
<!-- <add key="FilesPath" value="C:\DestinationFolde r\" /> --> works great with drives specified
<add key="FilesPath" value="\\90.xxx.xxx.xx\q$\ SourceFile s\" />
WINDOWS SERIVICE. (in short)
strfilesPath = ConfigurationSettings.AppS ettings.Ge t("FilesPa th")
stroldfilename = (here i get the file name i want to rename)
strNewFilename = stroldfilename + ".dat"
'RENAMING FILE
Rename(strfilesPath + stroldFileName, strfilesPath + newFileName)
dont knwo why it is not working when i use ip addres in my config file... can you tell me how to trap the error so i would atleat knwo it is because of the ip address i am entering or there is some problem in the service.
Note: service works file if i use Mapped drive letter
In my config file i have source path and destination path...
i am using these paths in my windows service to rename files...
if i use the map drives then it works but when i use 90.xxx.xxx.xx\somepath then it doesnt work.
Note i have tried to change user account to the accout that has access to the above path...
Need assistance to create a log file so i would now what error is happening and how do i resolve this. below is my config file and code from windows service to rename the destination files
CONFIG FILE
<!-- <add key="FilesPath" value="C:\DestinationFolde
<add key="FilesPath" value="\\90.xxx.xxx.xx\q$\
WINDOWS SERIVICE. (in short)
strfilesPath = ConfigurationSettings.AppS
stroldfilename = (here i get the file name i want to rename)
strNewFilename = stroldfilename + ".dat"
'RENAMING FILE
Rename(strfilesPath + stroldFileName, strfilesPath + newFileName)
dont knwo why it is not working when i use ip addres in my config file... can you tell me how to trap the error so i would atleat knwo it is because of the ip address i am entering or there is some problem in the service.
Note: service works file if i use Mapped drive letter
ASKER
this is great i didt not we can step through the windows service...
can you guide me a little more how would i do that.. i appreciate it
can you guide me a little more how would i do that.. i appreciate it
With the service running, start your IDE, go to Tools / Debug Processes, turn on the two checkboxes to show you all processes, select your service from the list box, attach, ok and then close.
The debugger is now running on your service. Set a breakpoint and you're set. The only problem with this is you can't easily debug code that runs during the OnStart event because you can't attach fast enough. If that's the case, let me know and I could explain a work-around.
The debugger is now running on your service. Set a breakpoint and you're set. The only problem with this is you can't easily debug code that runs during the OnStart event because you can't attach fast enough. If that's the case, let me know and I could explain a work-around.
ASKER
Thanks but i would like to know the work around as my code is in onStart()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In general, you want a try/catch block at the top of your call stack. If you are using a timer or filewatcher it would be that event handler. Then in your catch block you can write out the exception description to the event log using something as simple as Me.EventLog.WriteEntry(ex.