Hi Ali,
Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, you encountered the
"System.Security.SecurityException: Requested registry access is not
allowed."
exception when try to add eventlog via
"System.Diagnostics.EventLog.WriteEntry(string);" in ASP.NET application.
If there is anything I misunderstood, please feel free to let me know.
Based on my research, this seem to be a common issue which is due to :
By default, the user token of the ASP.NET worker process is ASPNET (or
NetworkService for applications that run on Internet Information Services
[IIS] 6.0). The problem in the "Symptoms" section occurs because your
account does not have the correct user rights to create an event source.
Also, there is a KB article which has provided the solution on this issue,
you may check it out to see whether it helps:
#PRB: "Requested Registry Access Is Not Allowed" Error Message When ASP.NET
Application Tries to Write New EventSource in the EventLog
http://support.microsoft.com/?id=329291
If you have need any further assistance, please feel free to let me know.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)