【发布时间】:2011-08-14 21:43:09
【问题描述】:
我正在尝试创建一个 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();
}
}
【问题讨论】:
-
“我将 Account 和 Password 都设置为 null,Account 设置为 Local System。” - 你是如何将同一个属性设置为两个不同的东西的……?跨度>
-
` processInstaller.Account = ServiceAccount.LocalSystem; processInstaller.Username = null; processInstaller.Password = null; `
-
sry 我没注意到我说了两次帐户:/
-
如果您发布了一些代码,我们或许可以为您提供帮助。
-
尝试以管理员权限运行“installUtil”命令。
标签: c# windows windows-services event-log