locked
System.Security.SecurityException: Requested registry access is not allowed. RRS feed

  • Question

  • User630885590 posted
    Hi

    I have just installed the June 2005 Enterprise library. I am trying to use the Exception Management Block with Logging to log exceptions to the windows event log.

    I have checked out various blogs on how to fix my problem but with no joy.
    http://blogs.msdn.com/tomholl/archive/2005/02/18/376187.aspx
    http://scottonwriting.net/sowblog/posts/3406.aspx

    I have run InstallServices.bat with no problem. I know that they have been run correctly as the ExceptionHandlingWithLoggingQuickStart now works correctly. (Previously I was getting instrumentation errors as well as the logging error).

    Any other ideas that you can share with me would be fantastic. The full error is below.

    Server Error in '/AWebSite' Application.

    Security Exception

    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.

    Source Error:

    Line 50: 			catch( InvalidOperationException ioe )
    Line 51: 			{
    Line 52: 				if( ExceptionPolicy.HandleException( ioe, "Log Only Policy" ) )
    Line 53: 					throw;
    Line 54: 			}

    Source File: c:\somepath\business\security.cs    Line: 52

    Stack Trace:

    [SecurityException: Requested registry access is not allowed.]
       Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +473
       System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly) +295
       System.Diagnostics.EventLog.SourceExists(String source, String machineName) +77
       System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +178
       System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) +21
       System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID) +15
       Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EventLogger.Log(String message)
       Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.FireEvent(String message)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.ExceptionHandlingEvent.FireAuxEvent(String message)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.ExceptionHandlingConfigFailureEvent.FireEvent(String message, Exception ex)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.ExceptionHandlingConfigFailureEvent.FireEvent(String message)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.ExceptionHandlingConfigFailureEvent.Fire(String message)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyFactory.PublishFailureEvent(String name, Exception e)
       Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationFactory.CreateInstance(String configurationName)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyFactory.CreateExceptionPolicy(String policyName, Exception exception)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ConfigurationContext configurationContext)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception ex, String policyName, ConfigurationContext configurationContext)
       Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception ex, String policyName)
       Business.Authentication.AuthenticateUser(Int32 countryId, String userName, String password) in c:\somepath\business\security.cs:52
       WebService.Proxy.Authentication.AuthenticateUser(Int32 countryId, String userName, String password) in C:\somepath\WebService.Proxy\Security.cs:34
       AWebSite._Default.EnterButton_OnClick(Object sender, EventArgs e) in C:\somepath\Default.aspx.cs:44
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain() +2106
       System.Web.UI.Page.ProcessRequest() +218
       System.Web.UI.Page.ProcessRequest(HttpContext context) +18
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
    


    Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
    <!-- [SecurityException]: Requested registry access is not allowed. at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly) at System.Diagnostics.EventLog.SourceExists(String source, String machineName) 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 Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EventLogger.Log(String message) at Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.FireEvent(String message) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.ExceptionHandlingEvent.FireAuxEvent(String message) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.ExceptionHandlingConfigFailureEvent.FireEvent(String message, Exception ex) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.ExceptionHandlingConfigFailureEvent.FireEvent(String message) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.ExceptionHandlingConfigFailureEvent.Fire(String message) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyFactory.PublishFailureEvent(String name, Exception e) at Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationFactory.CreateInstance(String configurationName) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyFactory.CreateExceptionPolicy(String policyName, Exception exception) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ConfigurationContext configurationContext) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception ex, String policyName, ConfigurationContext configurationContext) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception ex, String policyName) at DiData.Ptf.Business.Authentication.AuthenticateUser(Int32 countryId, String userName, String password) in c:\development\projects\fintrax\didata.ptf.business\security.cs:line 52 at DiData.Ptf.WebService.Proxy.Authentication.AuthenticateUser(Int32 countryId, String userName, String password) in C:\Development\Projects\Fintrax\DiData.Ptf.WebService.Proxy\Security.cs:line 34 at PtfWebSite._Default.EnterButton_OnClick(Object sender, EventArgs e) in C:\Inetpub\wwwroot\PtfWebsite\Default.aspx.cs:line 44 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain() at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) -->
    Wednesday, September 7, 2005 6:50 AM

All replies

  • User1112313556 posted
    Hi,
    I have this same problem.  I tried several solutions that are suggested on the google. But it still doesn't work. I just wonder if you figure out the problem.  Please give me some pointer if you do.
    Wednesday, September 14, 2005 9:42 AM
  • User630885590 posted

    Unfortunately I could not solve this particular problem. I got this when I was trying to use a policy that didn't exist in my configuration. So I managed to sweep it under the cover by using a policy name that does exist.

    The policy "Log Only Policy" is from the example, but when I configured my own I created a policy called "MyPolicy" (for example). My exceptions log to the event log fine, so I still don't know what is happening, but as I have hidden the problem I am going with sticking my head in the sand for now.

    Wednesday, September 14, 2005 11:43 AM