Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2003, 10:34 PM
Authorized User
 
Join Date: Jul 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET C# Writing to Event Log Problem

Hi guys,

    How r u doing there? I got a problem here ! The following is the C# code:

<%@ Import Namespace="System.Diagnostics" %>
<script Language="c#" runat="server" >
  void EntrytoLog()
  {
    int[] array = new int[9];
    for(int intCounter=0; intCounter <= 9;intCounter++)
    {
       array[intCounter] = intCounter;
       Response.Write("The value of the counter is:" + intCounter + "<br>");
    }
  }
  void Page_Error(object sender, EventArgs e)
  {
    string errorMessage = "Error occurred" + Server.GetLastError();
    Server.ClearError();
    string LogName = "MyApplicationLog";
    string SourceName = "MyApplicationSource";
    if (!(EventLog.SourceExists(SourceName)))
    {
       EventLog.CreateEventSource(SourceName, LogName);
    }
    // Insert into Event Log;
    EventLog MyLog = new EventLog();
    MyLog.Source = SourceName;
    MyLog.WriteEntry(errorMessage, EventLogEntryType.Error);
  }
</script>
<%
 EntrytoLog();
%>

which I got it from Wrox Beginning ASP.NET using C# book. When try to execute the page, I got the following error message:

================================================== ===============
Exception Details: System.Security.SecurityException: Requested registry access is not allowed.

Source Error:

Line 18: if (!(EventLog.SourceExists(SourceName)))
Line 19: {
Line 20: EventLog.CreateEventSource(SourceName, LogName);
Line 21: }
Line 22: // Insert into Event Log;

================================================== ===============

I am loggin in as administrator !!
Pls help !!
 
Old July 26th, 2003, 04:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Your ASP.NET account must have write permission on the file named C:\WINNT\system32\config\AppEvent.Evt.

...but the Soon is eclipsed by the Moon





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to log to server's event log LenexaKS Access VBA 4 March 11th, 2008 12:49 PM
DataList ItemCommand event problem in ASP.NET page naidukap ASP.NET 1.0 and 1.1 Professional 0 December 26th, 2005 03:26 AM
AppException Class -Log Error to Event Log bekim BOOK: ASP.NET Website Programming Problem-Design-Solution 7 December 7th, 2004 01:01 PM
Security exception comes when writing to event log s_vermani BOOK: Beginning ASP.NET 1.0 4 October 21st, 2004 09:17 AM
log out problem in ASP.net aravwind General .NET 3 July 19th, 2004 09:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.