我正在尝试创建Windows服务,但是当我尝试安装它时,它会回滚并出现以下错误:
System.Security.SecurityException:找不到源,但是无法搜索某些或所有事件日志。不可访问的日志:安全性。
我不知道这意味着什么-我的应用程序只有最低要求,因为我只是先进行测试。
我的安装程序代码:
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();
}
}