我刚刚构建了一个简单的Windows服务,但是无法启动它
The Commit phase completed successfully.
The transacted install has completed.
M:\MyDocuments\Visual Studio 2013\Projects\WindowsService1\WindowsService1\bin\Debug>Net start WindowsService1.exe
System error 2 has occurred.
The system cannot find the file specified.
代码位于映射的网络驱动器上,我将服务帐户设置为
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
这是某种权限问题吗?是否有任何工具或实用程序来诊断此类问题?
更新:代码只是一个空服务
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
}
protected override void OnStop()
{
}
}
}
更新2:错误是我启动服务时,而不是安装时。我正在成功运行以下命令
M:\MyDocuments\Visual Studio 2013\Projects\WindowsService1\WindowsService1\bin\Debug>installutil WindowsService1.exe
答案 0 :(得分:0)
代码位于映射的网络驱动器上,我将服务帐户设置为:
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
听起来像问题。 LOCALSERVICE帐户无权查看网络驱动器。至少该过程需要能够查看其可执行文件。失败机制究竟是什么,我不确定,但肯定这是根本原因。
将文件放到本地驱动器上,然后重试。