Re: Security Error when trying to create an Event log

From: Curtis Tammany (tammanyc@egginc.com)
Date: 11/01/02


From: "Curtis Tammany" <tammanyc@egginc.com>
Date: Fri, 1 Nov 2002 16:16:33 -0500

I solved my problem- I added <identity impersonate="true"/> to the <system.web> section the web.config file.
I'm not sure why it works now, but it does.

Curtis
  "Curtis Tammany" <tammanyc@egginc.com> wrote in message news:OS$e80dgCHA.2308@tkmsftngp12...
  Hello and Help!

  I'm trying to create and write to an event log:

    Sub Page_Error(sender As Object, exc As EventArgs)
      dim errorMessage as string
      errorMessage = "Error occurred" & Server.GetLastError().ToString()
      Server.ClearError()
      Dim LogName As String = "MyApplicationLog"
      Dim SourceName As String = "MyApplicationSource"
      If (Not EventLog.SourceExists(SourceName))
        EventLog.CreateEventSource(SourceName, LogName)
      End If

      'Insert into Event Log
      Dim MyLog As New EventLog
      MyLog.Source = LogName
      MyLog.WriteEntry(errorMessage, EventLogEntryType.Error)
    End Sub
  When this sub is called, I get the error:
  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.

  I've added <trust level="Full" /> to the <system.web> section of my web.config file but I get the same error. What else do I need to do ????

  Thanks!

  Curtis



Relevant Pages

  • Re: Vba printout
    ... >> End Sub ... > I still dont have a clue on how to solve this problem. ... the printout creates a postscript file then you convert the postscript ...
    (microsoft.public.excel.programming)
  • Re: Windows Service Remoting Question
    ... Why you don't see anything in the event log I'm ... >> Sub Main ... >> service server. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Max number of items in a listbox?
    ... >> ListBox as sort of an event log. ... >> limiting the number of entries that can accumulate in this listbox ... >Sub AddLogEntry ...
    (microsoft.public.vb.general.discussion)
  • Write log description
    ... Private Sub Page_Load(ByVal sender As System.Object, ... Sub WriteToEventLog(ByVal LogName As String, ... 'Create event log if it doesn't exist ...
    (microsoft.public.dotnet.general)
  • Re: Windows Services
    ... Public Class MyService ... End Sub ... Note EventLog is inherited from ServiceBase and will be the normal event log ...
    (microsoft.public.dotnet.languages.vb)