Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution 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
  #1 (permalink)  
Old April 14th, 2005, 04:39 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to axislover
Default about Event Viewer Error

my system is: winxp sp2 .net1.1 sp1

Error:

Access is denied
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: Access is denied

Source Error:


Line 31: EventLog.CreateEventSource("ThePhile.COM", "Application");
Line 32: }
Line 33: EventLog.WriteEntry("ThePhile.COM", message, entryType);
Line 34: }
Line 35:

how to fix this problem?

  #2 (permalink)  
Old April 14th, 2005, 11:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Atlanta, Georgia, USA.
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is a frequently asked question that is covered in the index.htm file in the code download.

The problem is that the ASPNET user account doesn't have permission to create an event source (this is the way Microsoft designed it). There are 3 possible solutions given in the index.htm file, but I don't care for any of them.

My personal favorite fix is to have you create the event source yourself by running a console mode program (this runs with your personal rights, and you are probably an administrator, so this should work).

Compile this C# code as a console application and run it (it doesn't matter if you are mostly a VB.NET coder - this is just a trivial program that will create your event source):

using System;
using System.Diagnostics;
using System.Threading;

class MySample
{
  public static void Main()
  {
    // Create the source, if it does not already exist.
    if (EventLog.SourceExists("ThePhile.COM"))
    {
      Console.WriteLine("Source already exists");
    }
    else
    {
      Console.WriteLine("Creating Event Source");
      EventLog.CreateEventSource("ThePhile.COM", "Application");
    }

    // Create an EventLog instance and assign its source.
    EventLog myLog = new EventLog();
    myLog.Source = "ThePhile.COM";

    // Write an entry to the event log as a test.
    myLog.WriteEntry("ThePhile test message");

    Console.Write("Message written to eventlog. Press Enter...");
    Console.ReadLine();
  }
}

Then look in the Windows event log for the test message. Your web app should be able to write to this same event source.

Eric
  #3 (permalink)  
Old July 4th, 2005, 10:42 AM
Authorized User
 
Join Date: Apr 2004
Location: glasgow, , United Kingdom.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can run this program and get the correct output/error log.Problem is my web page still flags the CreateEventSource error.strange.
  #4 (permalink)  
Old July 4th, 2005, 11:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Atlanta, Georgia, USA.
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This article explains your 2 options (the 2 most reasonable options, anyway):

http://support.microsoft.com/default...b;en-us;842795

You can either create the event source as an administrator, or you can grant write access to your user accounts using the registry so they can create event sources themselves.

But please don't run ASP.NET using the high priviledge SYSTEM account - this would not be a wise choice for security reasons. You want your web account to have the least permissions necessary to run.

Eric


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with Crystal Reports Viewer in ASP.NET jaucourt Crystal Reports 2 February 24th, 2012 03:39 PM
c# crystal report viewer - login error beuls Crystal Reports 3 July 20th, 2011 06:54 AM
Viewer error Ned Crystal Reports 1 July 23rd, 2004 10:55 PM
Event Viewer can't display my events steveg General .NET 0 April 14th, 2004 10:50 AM





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