FIX: nHibernate/log4net in windows service. FileNotFoundException

When using nHibernate in a windows service you may find that you encounter FileNotFoundExceptions when trying to load assemblies or external configuration files. Typically this is in scenarios where you are running your service under a user context such as NetworkService.

If you hunt around long enough you will find that it is trying to locate said files in the %WINDIR%\system32 folder (for example c:\windows\system32), and not from the services own directory.

By default window services set the default directory to the %WINDIR%\system32.

Simply change your service’s default directory to wherever your service is running.

Here’s a sample: