EntLib5 + Windows service

Topics: Enterprise Library Core
Sep 16, 2013 at 10:41 AM
Hello,
we ran into a strange problem: a windows service uses entlib 5 for logging. When started as a service on a developer workstation (win7, x64) everything is fine, it starts, works and logs.

When installed as a service on windows server 2003 & 2008 the service will not start.

As soon as the code hits something like "new LogEntry()" it hangs, meaning the start service will throw a timeout exception, but no other exception is logged anywhere not even in the windows log.

We believe it might has something to do with the user account under which the service should start. Maybe it has some right revoked or not set on the domain controller.

Question is: does entlib 5 need some "special" rights?

This sounds strange, I know, but the program code is self is working under a normal developer account, so there is no coding or configuration error in the program it self.
Sep 17, 2013 at 8:23 AM
When you instantiate a LogEntry the default formatter is created and it does call into the Kernel32 to retrieve some information so it's possible that a deadlock is occurring in unmanaged code. What happens on Windows 2003/2008 if you give the service different credentials (e.g. Network Service)? Does it start or does it also hang?

You could also try adding this to the config:
<configuration>
    <runtime>
        <generatePublisherEvidence enabled="false"/>
    </runtime>
</configuration>
~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Marked as answer by randylevy on 10/7/2013 at 11:00 PM
Sep 18, 2013 at 7:55 AM
Yes, we tried different credentials, even as local administrator the service wouldn't start. Adding your code snippet changed everything.
The service started and wrote log entries :)
Interesting, would you like to explain what that configuration means?
Sep 20, 2013 at 6:44 AM
Good to hear that it is working. Setting generatePublisherEvidence to false tells the runtime to not createa Publisher evidence for code access security (CAS). My understanding is that this involves Authenticode but in this case we don't need that so we can turn it off. It's not 100% clear to me what the runtime is doing under the covers since I don't believe Authenticode would be in play here (perhaps going out to a obtain a CRL even if not needed) but the recommendation is to turn it off:
We recommend that services use the <generatePublisherEvidence> element to improve startup performance. Using this element can also help avoid delays that can cause a time-out and the cancellation of the service startup.
~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to