0
votes
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Custom_Event_Log_App
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button_EventAndSourceLog_Click(object sender, EventArgs e)
        {
            if (textBox_LogName.Text != string.Empty && textBox_LogSource.Text != string.Empty)
            {
                System.Diagnostics.EventLog.CreateEventSource(textBox_LogSource.Text, textBox_LogName.Text);
                MessageBox.Show("Event Log and Source Created");
            }
            else
            {
                MessageBox.Show("Event Log and Source is Required...!");

            }
        }
    }
}

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

Stack Trace:

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

1
you need admin rights to create an event source. Which is what the error is telling you. I suggest creating the event source on the server in advance as part of your deployment process, rather than relying on the app to do it (because the app should not have admin rights!)ADyson
Thanks you for the helpwifiboy

1 Answers

0
votes

Run Your Visual Studio as an Administrator .then u will get all the RIGHTS of administrator .that's it .Problem is solved