本文介绍了System.Security.SecurityException:找不到源,但是无法搜索某些或所有事件日志.无法访问的日志:安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建Windows服务,但是当我尝试安装它时,它会回滚并出现以下错误:

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

我不知道这意味着什么-我的应用程序只有最低要求,因为我只是先进行测试.

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

我的安装程序代码:

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)
        {
        }
    }
}

我的服务代码:

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();
    }
}

推荐答案

如果系统提示您输入用户名和密码,则某些地方设置为Account = ServiceAccount.User-这是(应该)发生的唯一方法.也许上面注释中的代码没有被执行,或者被稍后执行的代码改回了.

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.

一般而言,对于第二段,如果您不希望在控制台上看到它或将其作为任务运行,则我认为服务会很好.我不确定我是否了解将其作为ASP.NET运行并不允许您查看数据库的那一部分...

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...

最后,在您的最后一段中,如果您不了解安装程序代码中发生的一切,我将无法与NullExeception对话.

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:找不到源,但是无法搜索某些或所有事件日志.无法访问的日志:安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:05