Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 25th, 2003, 10:34 PM
Authorized User
Join Date: Jul 2003
Location: , , .
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();
    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);

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 !!
  #2 (permalink)  
Old July 26th, 2003, 04:08 AM
Friend of Wrox
Join Date: Jun 2003
Location: Wien, Wien, Austria.
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 04:25 AM.

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