Windows服务无法正常运行

瓦加尔·艾哈迈德·索姆拉

我已经使用Visual Studio创建了服务,并使用Visual Studio命令提示符安装了该服务。工作正常

但是现在我想使用Visual Studio安装程序安装相同的服务。我通过点击此链接创建了一个安装程序安装程序会正确安装服务,因为它不会引发任何错误或异常。但是,当我从服务列表中启动服务时,该服务会启动,但不会写入日志文件。因此,任何人都可以帮助我,并说明为什么使用命令提示符安装该服务时执行OK的原因,但是通过安装程序安装时却引起问题。

protected override void OnStart(string[] args)
{
    timer1 = new Timer();
    this.timer1.Interval = 5000;
    this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_tick);
    timer1.Enabled = true;
    Library.WriteErrorLog("service started!");
}

private void timer1_tick(object sender, ElapsedEventArgs e) 
{ 
    Library.WriteErrorLog("Timer ticked succesfully"); 
}

protected override void OnStop()
{
    timer1.Enabled = false;
    Library.WriteErrorLog("Service Stopped!");
}
特里·伦诺克斯(Terry Lennox)

您是否检查过该服务是否有权写入日志文件?

检查目录的权限,转到日志文件夹-“属性”和“安全性”选项卡。

服务通常在没有对Windows文件系统的写访问权的情况下运行。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

DHCP服务器无法正常运行Windows Server 2012

Windows服务恢复-运行程序无法正常工作

Android Google Play服务无法正常运行

GooglePlayGame服务无法在Unity中正常运行

Windows服务,它将无法运行多个服务

从phonegap构建的Windows应用无法正常运行

PuTTY无法正常运行(Windows 8)

更新IONIC无法正常运行(Windows)

在Kubernetes中运行服务的配置文件无法正常运行

wbadmin命令无法从Windows服务运行

无法查询,运行或停止Windows服务

Indy http服务器会话无法正常运行

服务中的计时器无法正常运行

Windows 10 Updater无法正常运行(0x80080005)并且Windows Updater服务将无法启动(0x80070002)

旧游戏在Windows 8中无法正常工作/ Windows 8中的旧游戏无法正常运行

WAMP服务器在Windows 10上无法正常工作

会话在Windows服务应用程序中无法正常工作?

.vbs文件无法从Windows服务正常工作

如何修复GRUB Bootloader(Windows 10无法正常运行)

重定向的WebRequest的cookie无法正常运行(Windows Build 15063)

Yubikey 4无法正常运行(Linux和Windows)

任务栏无法正常运行Windows 10

PowerShell脚本无法从Windows Task Scheduler中正常运行

Pycharm终端无法在Windows 10上使用VirtualEnv正常运行

安装Windows更新后,HttpHandler中的会话无法正常运行

Windows Mobile多任务在CF 3.5中无法正常运行

服务无法正常工作?

DIR无法正常运行

Pygame无法正常运行