Thursday, February 16, 2012

Access Denied - nothing to see here, move along...

While writing my first .net service, I encountered the following problem:

The service would not start. In the Application event log there was an error:

Service can not be started.  FileLoadException: Could not load file 'dll name'. Access is denied.
....
Pre-bind state information
====================
...
<log message cut off>

Well, in the web there was nothing helpful, and the fact the event log was cut off made the error even more mysterious in my eyes, as I kept thinking the last part holds the key.

But, alas, I was the one creating the problem.  I had a post-build script that updates the service's files and I didn't notice it copies files in encrypted (EFS) form.
Of course, the Local Service (or Local System) accounts can't access EFS files, thus the error.