Getting exception from CreateEventSource

P

Philip Colmer

I'm trying to set up event logging in my web service. The code is as
follows:

Const AppName = "Fred"
Dim objEventLog As New EventLog

Try
'Register the App as an Event Source
If Not objEventLog.SourceExists(AppName) Then
objEventLog.CreateEventSource(AppName, Nothing)
End If

objEventLog.Source = AppName
objEventLog.WriteEntry("Test")

LogOutcome = ""
Catch Ex As Exception
LogOutcome = Ex.ToString
End Try

I'm getting an exception at the call to CreateEventSource:

System.Security.SecurityException: Requested registry access is not allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at
System.Diagnostics.EventLog.CreateEventSource(String source, String logName,
String machineName, Boolean useMutex) at
System.Diagnostics.EventLog.CreateEventSource(String source, String logName,
String machineName) at System.Diagnostics.EventLog.CreateEventSource(String
source, String logName) at
QuarantineService.QuarantineValues.LogOutcome(String strUser, String
strComputer, String strOutcome)

I'm not entirely sure what to do to resolve this. The web service is running
under the default app pool.

--Philip
 
P

Peter Huang [MSFT]

Hi

Based on my research, 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.

Here is a KB article you may have a look about the detailed resolution.
329291 PRB: "Requested Registry Access Is Not Allowed" Error Message When
http://support.microsoft.com/?id=329291

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Philip Colmer

"Peter Huang" said:
Hi

Based on my research, 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.

Here is a KB article you may have a look about the detailed resolution.
329291 PRB: "Requested Registry Access Is Not Allowed" Error Message When
http://support.microsoft.com/?id=329291

Many thanks for that. I've created the source installer and it has fixed my
problem.

--Philip
 
P

Peter Huang [MSFT]

Hi

I am glad that works for you!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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