T
TJO
We are experiencing the following error when writing to a custom log file:
"Requested registry access is not allowed."
We have created the custom log file using the code below and then add full
permissions to the ASPNET account at the Registry Key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.
We do not experience the error when writing to the "Application" Event log
or if we run the code from a windows form application.
// Code Fails when writing to custom event log "SR_AppLog
EventLog appLog = new EventLog("SR_AppLog", ".");
appLog.Source = "SR_AppDev";
appLog.WriteEntry("foo bar: database error");
appLog.Dispose();
//Code executs when writing to "Application" event log
EventLog appLog = new EventLog("Application");
appLog.Source = "SR_AppSrc";
appLog.WriteEntry("foo bar: database error");
appLog.Dispose();
//Installer class to create the custom event log
namespace EventLogSourceInstaller
{
[RunInstaller(true)]
public class MyEventLogInstaller : Installer
{
private EventLogInstaller myEventLogInstaller;
public MyEventLogInstaller()
{
//Create Instance of EventLogInstaller
myEventLogInstaller = new EventLogInstaller();
// Set the Source of Event Log, to be created.
myEventLogInstaller.Source = "SR_AppDev";
// Set the Log that source is created in
myEventLogInstaller.Log = "SR_AppLog";
// Add myEventLogInstaller to the Installers Collection.
Installers.Add(myEventLogInstaller);
}
}
}
"Requested registry access is not allowed."
We have created the custom log file using the code below and then add full
permissions to the ASPNET account at the Registry Key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.
We do not experience the error when writing to the "Application" Event log
or if we run the code from a windows form application.
// Code Fails when writing to custom event log "SR_AppLog
EventLog appLog = new EventLog("SR_AppLog", ".");
appLog.Source = "SR_AppDev";
appLog.WriteEntry("foo bar: database error");
appLog.Dispose();
//Code executs when writing to "Application" event log
EventLog appLog = new EventLog("Application");
appLog.Source = "SR_AppSrc";
appLog.WriteEntry("foo bar: database error");
appLog.Dispose();
//Installer class to create the custom event log
namespace EventLogSourceInstaller
{
[RunInstaller(true)]
public class MyEventLogInstaller : Installer
{
private EventLogInstaller myEventLogInstaller;
public MyEventLogInstaller()
{
//Create Instance of EventLogInstaller
myEventLogInstaller = new EventLogInstaller();
// Set the Source of Event Log, to be created.
myEventLogInstaller.Source = "SR_AppDev";
// Set the Log that source is created in
myEventLogInstaller.Log = "SR_AppLog";
// Add myEventLogInstaller to the Installers Collection.
Installers.Add(myEventLogInstaller);
}
}
}