Security Issue in Service

B

bthubbard

Hello All,
I've run into a bit of an issue and I was hoping that someone here
could help me. I have inherited a Windows Service written in .Net 2.0
(C#) from a previous employee. It build successfully and I am able to
install it on the target machine via installutil but when I attempt to
run it I receive a security error. First I receive the dialog telling
me that the service could not be started "Error 1053: The service
did..." and then "An unhandled exception of type
'System.Security.SecurityException' occurred in System.dll" . I've
tried running the service on my local machine and opening the CLR
debugger and the errors seems to be related to EventLog.WriteEntry.
I've found the support article
http://support.microsoft.com/?kbid=918122 and have added the

EventLogPermission eventLogPermission = new
EventLogPermission(EventLogPermissionAccess.Administer, ".");
eventLogPermission.PermitOnly(); to no avail.

Any help would be greatly appreciated.
 
W

Willy Denoyette [MVP]

| Hello All,
| I've run into a bit of an issue and I was hoping that someone here
| could help me. I have inherited a Windows Service written in .Net 2.0
| (C#) from a previous employee. It build successfully and I am able to
| install it on the target machine via installutil but when I attempt to
| run it I receive a security error. First I receive the dialog telling
| me that the service could not be started "Error 1053: The service
| did..." and then "An unhandled exception of type
| 'System.Security.SecurityException' occurred in System.dll" . I've
| tried running the service on my local machine and opening the CLR
| debugger and the errors seems to be related to EventLog.WriteEntry.
| I've found the support article
| http://support.microsoft.com/?kbid=918122 and have added the
|
| EventLogPermission eventLogPermission = new
| EventLogPermission(EventLogPermissionAccess.Administer, ".");
| eventLogPermission.PermitOnly(); to no avail.
|
| Any help would be greatly appreciated.
|

My guess is that your service attempts to create a "private log", only
admininstrator accounts have the right to "create" private logs. If your
service runs as localservice or networkservice (as it should), it won't be
able to create the log, so, you'll have to create the log from another
program, not from within your service.
Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top