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

eventlog.sourceexists inaccessible logs security
system.security.securityexception: requested registry access is not allowed.
create event log source
create event log under applications and services logs
powershell create event log source
c# write to event log
error logging in c# windows application
permission to create event log source

I am trying to create a Windows Service, but when I try and install it, it rolls back giving me this error:

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

I don't know what this means - my application has the bare minimum since I am just testing things out first.

My Installer Code:

namespace WindowsService1
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            //set the privileges
            processInstaller.Account = ServiceAccount.LocalSystem;
            processInstaller.Username = null;
            processInstaller.Password = null;

            serviceInstaller.DisplayName = "My Service";
            serviceInstaller.StartType = ServiceStartMode.Manual;

            //must be the same as what was set in Program's constructor
            serviceInstaller.ServiceName = "My Service";

            this.Installers.Add(processInstaller);
            this.Installers.Add(serviceInstaller);
        }

        private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
        {
        }

        private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
        {
        }
    }
}

My Service Code:

public partial class Service1 : ServiceBase
{
    public Service1()
    {
        this.ServiceName = "My Service";
    }

    protected override void OnStart(string[] args)
    {
        base.OnStart(args);
    }

    protected override void OnStop()
    {
        base.OnStop();
    }
}

If you are being prompted for a user name and password, then something, somewhere is set to Account = ServiceAccount.User - that's the only way that could (should) happen. Perhaps your code in the comment above is not being executed or it is being changed back by later executing code.

As far as your second paragraph, in general, I would think a service would be fine for this if you don't want it to be see on the console or run as a task. I am not sure if I understand the part about running it as ASP.NET and having it not allow you to see the database...

Finally, in your last paragraph, I can't speak to the NullExeception without knowing more about what is going on in your installer's code.

System.Security.SecurityException: The source was not found, but , Inaccessible logs: Security. if (!System. xlang/s engine event log entry: Uncaught exception (see the 'inner was not found, but some or all event logs could not be searched. System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.

I got the same exception when trying to install a service from the command line when using installutil in Windows 7. The solution was to open the command line as Administrator and then run installutil.

Also you may find it easier to use a framework like TopShelf to host your services, because it manages all the setup configuration from the name and description of the service to how your recovery process will work. It also allows to easily start your service from inside the IDE when you are debugging it.

[Solved] problem with creating an event log in event viewer , Inaccessible logs: Security. source was not found, but some or all event logs could not be searched. The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.

Run your command prompt as administrator. It will solve your problem

Error: The source was not found, but some or all event logs could not , Inaccessible logs: Security. REASON. This problem occurs because the user (​BizTalk Service) account  Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.

Run as Administrator

This is a very common issue that programmers are missing out

Error 'The source was not found but some or all event logs could not , The source was not found, but some or all event logs could not be searched. To create the source, you  By David Youngquist, Senior Support Engineer Tuesday, December 17, 2013 When running a SmartConnect map, getting an error that says “The source was not found, but some or all event logs could not be searched. To create the source, you need permission to real all event logs and to make sure that the new source name is unique.

I solve this same issue by opening the VS2013 Developer Console with administrative permissions.

https://social.technet.microsoft.com/Forums/en-US/, After logging in to EOC, the error below appears: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security. System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security. I don't know what this means - my application has the bare minimum since I am just testing things out first. My Installer Code:

eConnect "The source was not found, but some or all event logs , Exception Details: System.Security.SecurityException: The source was not found, but some or all event  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.

Creating EventLog source EmailFeedback in log Application. found, but some or all event logs could not be searched. Inaccessible logs: Security in ASP. SecurityException: The source was not found, but some or all eve. Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security. Inaccessible logs: Security. Source Error:

was not found, but some or all event logs could not be searched. Inaccessible logs: Security. Compare Brands Like: Secure Systems Save Time and Compare Top Brands. 24/7 Monitoring For 100% Peace of Mind. Find the Best Home Security System, Today

Comments
  • "I set both Account and Password to null and Account to Local System." - How did you set the same property to be two different things...?
  • ` processInstaller.Account = ServiceAccount.LocalSystem; processInstaller.Username = null; processInstaller.Password = null; `
  • sry i didnt notice i said account twice :/
  • Maybe if you posted some of your code we might be able to help you.
  • Try running the "installUtil" command with administrator rights.
  • As for the second paragraph, I have a lot of code that is doing processing, as I mentioned, its extracting rss feeds, collecting the data, parsing it and storing it into a database. I have an ASP.NET web application because I am providing the user with an interface so that he/she can see recommendations based on the data in my database. If there is a better method that I can use a background process in ASP.NET, i would gladly choose that..is there a way?
  • @michelle, Try removing the three lines of code that set the Account, Username, and Password. I am guessing that this is getting called after the installer looks at the properties and sees the default ServiceAccount.User, then asks for credentials, then you overwrite it with nulls. Try setting it on the property pages. Just a stab in the dark.
  • @michelle, as far as the other part of your comment, you mentioned about running a "background process in ASP.NET". Sorry, this is getting beyond my expertise. IF what you are trying to do can be done, it will probably require AJAX. AJAX provides a much richer Web UI experinece (for example, Google Maps uses AJAX, probably as well as Google search as you type things in results just appear). You will probably have better luck starting a new question that is tagged specifically that that.
  • This was the fix for me. Cheers.
  • Can't believe it happened to me. Again !
  • This should ideally be set as answer for this! :)
  • This was my issue. One service was fine but installing a second was failing.
  • This solved my issue as well, thanks.
  • This worked for me. Even though my account is in the Administrators group
  • I wasted 2 hours. Thanks!