Security exception comes when writing to event log
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
You are currently viewing the BOOK: Beginning ASP.NET 1.0 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
Security exception comes when writing to event log
I am trying to write to event log. When I run it I get a Security Exception message shown below. I am using windowsXP Pro and have administrator rights.
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.
Source Error:
Line 16: string LogName = "MyApplicationLog";
Line 17: string SourceName = "MyApplicationSource";
Line 18: if(!(EventLog.SourceExists(SourceName)))
Line 19: {
Line 20: EventLog.CreateEventSource(SourceName, LogName);
I read it on this forum that this can be fixed by changing the appEvent.evt file's security setting but I am not able to see the security tab for AppEvent.evt file. Please advice.
If you don't alread have a web.config file do this:
Create a new file and save it as "web.config" in either your root directory or the directory that contains the code that is trying to create the event log. Copy and paste the xml contents below into this file. Be sure to replace your actual computername/username and password (the same info you use to log into Windows) in the "identity" element below. Then attempt to run the code again. I had the same error, and this worked for me. Good luck!
You need to disable simple file sharing option exists under the TOOLS>>FOLDER OPTIONS>>VIEW TAB. This is the last item in list of options you get in VIEW TAB. After that you are able to use the security tab for any folder while viewing its properties.
Did you ever find an answer to this problem? I'm having the same difficulty... the only thing that has worked is to make my user an administrator of the machine, which is not acceptable.