我创建了一个小型可执行文件,它可以通过调用 MyApp.exe
作为普通应用程序启动,也可以通过调用 MyApp.exe -s
作为服务启动。因为我尽量保持简单,所以我通过手动运行来“安装”这个应用程序
sc create MyAppService binPath= "C:\MyApp\MyApp.exe -s"
然后我像往常一样使用 net start MyAppService
启动服务。
在两台 Windows XP 机器和两台 Windows 2000 机器上,这工作正常。但是,在两台不同的 Windows XP Embedded 机器上,当我尝试启动该服务时,我收到消息:
System error 1083 has occurred.
The executable program that this service is configured to run in does not implement the service.
在一台机器上,我能够通过卸载并重新安装 .NET 2.0 来解决这个问题,但在第二台机器上这不起作用。
我不确定如何调试它,并且搜索谷歌似乎只能找到失败并显示此消息的特定服务,例如 BITS 和 Exchange 服务。
下面是启动类MyApp
和扩展ServiceBase的类MyAppService
。在此先感谢您对此的任何指导。
MyApp.cs
static class MyApp
{
[STAThread] static void Main( string[] args )
{
....
switch ( arg1 )
{
case "-s":
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new MyAppService() };
ServiceBase.Run( ServicesToRun );
break;
....
}
}
}
MyAppService.cs:
class MyAppService : ServiceBase
{
static MyAppService()
{
// ...
}
protected override void OnStart( string[] args )
{
// ...
}
}
最佳答案
在桌面上,如果服务没有在 svchost 实例应该运行的帐户下正确注册到 Windows 注册表中,就会发生这种情况。我没有使用 XPe 的经验,但请尝试查看 HKLM\Software\Microsoft\Windows NT\CurrentVersion\Svchost 并确保为帐户正确列出了 MyAppService。
关于c# - 无法在 Windows XP Embedded 上启动以 .NET 2.0 编写的服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2413077/