.NET Framework Bookmark and Share   
 index > 64-Bit .NET Framework Development > How to create a new event source in event viewer?
 

How to create a new event source in event viewer?

if (!System.Diagnostics.EventLog.SourceExists("ApplicationName"))
System.Diagnostics.EventLog.CreateEventSource(
"ApplicationName", "Application");

System.Diagnostics.EventLog EventLog1 = new System.Diagnostics.EventLog();
EventLog1.Source = "ApplicationName";
EventLog1.WriteEntry("This is a simple event log entry");

The above code gives me the following error message:

System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.

I have added ASP.NET user to the ADMINISTRATORS group as well but it didn't help

Dynamic

Hi Dynamic,

As you said, it’s definitely a security issue, СђrΐsτσρhΞr ScЋδlτξη has provided detail analysis on this issue, you will be glad to see his article from here.

Thanks,

Eric


Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang
I had to edit the registry manually to add an event source key there

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application

But why it's not possible using code? I can't event run EventLog.SourceExists method.

It's obviously a security issue but how can I resolve it? I am member of ADMINISTRATORS, ASP.NET account and batch_user_service account (which appears as my Environment.UserName) are members of ADMINISTRATORS.
Dynamic

Hi Dynamic,

As you said, it’s definitely a security issue, СђrΐsτσρhΞr ScЋδlτξη has provided detail analysis on this issue, you will be glad to see his article from here.

Thanks,

Eric


Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang

You can use google to search for other answers

Custom Search

More Threads

• assembly generation warning messages
• We've totally stuck, please help!!
• Calling 32 bit COM component from C# .NET on 64 bit Win2008 server - events not firing
• Access to 64 bits registry from 32-bit application
• How do you install OWC on Vista 64?
• Error on new x64 Windows 2003 server from IIS when executing ASP.NET code.
• About debugging a 64bit program?
• Where do I get development tools for x64
• A generic error occured in GDI+
• Installing Microsoft Visual C++ 2005 Redistributable