Solved

Can't Access event log through VB.Net on Windows server 2008 with IIS 7.0

Posted on 2008-06-24
3
1,439 Views
Last Modified: 2013-11-07
I am catching errors in my web app and writing custom error messages to the application log. The application is deployed on WIndows Server 2008 running IIS 7.0. When an error occurs and tries to write to the log 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: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.

how can it be fixed? on the provided snippet the error occurs in the second line "If not eventlog.sourceexists...."

scd.MachineName = "."
        If Not EventLog.SourceExists(scd.Source, scd.MachineName) Then
               EventLog.CreateEventSource(scd)
        End If

Open in new window

0
Comment
Question by:gregx1973
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
philipjonathan earned 500 total points
ID: 21855736
It's something to do with permission.
One shortcut, if you just need to run this on a specific server, you can write a Winforms app, just to create the said event log and source.
Afterwards, you would be able to use this event log and source from your web app / IIS.
0
 

Author Comment

by:gregx1973
ID: 21855878
but the exception does not occur when I am trying to create the source. It's happening when it checks to see if the source exists
0
 
LVL 18

Expert Comment

by:philipjonathan
ID: 21862921
Hmm, if manage to create the event log and source somehow using Winform, you don't need to check whether it exists in your actual code.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question