C # Windows Service doesn't seem to like privatePath
I wrote a C # Windows Service to handle task scheduling for our application. I'm trying to move the business rule assemblies to the bin subdirectory of the scheduling application to make it easier for us to make updates (stop the service, delete all files in the bin folder, replace them with new ones, start the service).
I added
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;"/>
</assemblyBinding>
</runtime>
into the configuration of the service application and works fine if the service is started as a console application. The problem is the service starts as a windows service, it doesn't work. It looks like when windows starts the service, the application config file is read correctly, but then the service is executed as if it was in c: \ windows \ system32 and not actually in the EXE location, and this rattles work.
We have a lot of assemblies, so I really don't want to use the GAC or <codeBase>
. Is it possible that the EXE will change the base directory to its original location when it runs as a service?
a source to share
It turns out I was wrong. privatePath works fine even with windows service. The problem was that I added a section <runtime>
at the beginning of the app.config that throws an error because it is <configSections>
not the first item in the file. However, the service still signaled that it started fine (something we have to fix) and the log file used for startup errors was being written to a directory different from the one with the EXE (something ELSE we should fix), once I moved the <runtime>
lock to its proper location in app.config everything works fine.
Kudos to the comment on the fuslogvw.exe file, I would give you an answer if I could. This allowed me to see that privatePath observance followed, and that the error was elsewhere.
a source to share