SecurityException when trying to write to event log.

  • Thread starter Thread starter Suhail Salman
  • Start date Start date
S

Suhail Salman

Dear all,
why do i get the following exception when i try to write to the event
log from a webform. and how can i resolve it?

Description:
The application attempted to perform an operation not allowed by the
security policy. To grant this application the required permission please
contact your system administrator or change the application's trust level in
the configuration file.

Exception Details: System.Security.SecurityException: Requested registry
access is not allowed.

i changed the trust level in my computer zone to full trust. but its still
the same, even though that this exception is thrown from a dll which is
referenced in the major project.

thank you for your help.
suhail
 
Suhail Salman said:
Dear all,
why do i get the following exception when i try to write to the event
log from a webform. and how can i resolve it?

Description:
The application attempted to perform an operation not allowed by the
security policy. To grant this application the required permission please
contact your system administrator or change the application's trust level in
the configuration file.

Exception Details: System.Security.SecurityException: Requested registry
access is not allowed.

i changed the trust level in my computer zone to full trust. but its still
the same, even though that this exception is thrown from a dll which is
referenced in the major project.

This problem usually occurs when there is no event source defined. The first
write to the event source will try to create it. That's what you don't have
access to do.

Create the event source manually first. Look into the EventLogInstaller
class.
 
The problem is that the aspnet account, by default, does not have the
security rights to create the event log application. You can manually
create this by editing the registry. Go to
HKLM\System\CurrentControlSet\Services\EventLog\Application and add a node
underneath with the name of the application you are reporting in the event
log.

You can find the MS article on this problem here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;329291&Product=aspnet
Jeff
 
Back
Top