Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requested registry access is not allowed

Status
Not open for further replies.

lpatnaik

Programmer
Jul 11, 2002
53
Hi,

My webservice is currently deployed on WIndows 2000 server and runs pretty fine. I am trying to run my webservice on a Windows 2003 server. My webservice tries to write to a eventlog. The code is as follows:

System.Diagnostics.EventLog Log = new System.Diagnostics.EventLog( EventLogName );
Log.Source = EventLogName;
Log.WriteEntry( "PCHistory Service Application started up successfully.", System.Diagnostics.EventLogEntryType.Information );

I am getting the following error.

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.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type)
at PCHistory.PCHistoryService.Log(String Message, EventLogEntryType type)
at PCHistory.PCHistoryService.LogInfo(String Message, Object[] args)
at PCHistory.PCHistoryService..ctor()

I tried the following:
1. Giving full rights to ASPNET account on HKLM\System\CurrentControlSet\Services\Eventlog
2.Giving SetValue and CreateSubkey rights to ASPNET account on the same.
3.Changing machine .config process model attribute of USerName to SYSTEM.
4. Creating the Source manually in the registry.

Nothing worked.

If u have solution please reply ASAP.

Thanks
LP
 
I've had this problem before on a win2k machine so it's not restricted to win2k3. Although there are microsoft knowledge base articles on it I never managed to find a solution to it on that machine. Transfering the code to a seperate win2k machine solved the issue for me but I realise that's not exactly an ideal solution.

Here's a couple of the knowledge base articles just in case you havn't tried them but I suspect you already may have.



I thought it might be trying to use the web user account rather than the ASPNET account, never got round to investigating it further though.

Can you get the code to work as part of a console app on the server to confirm which account it is using?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top