无法在Windows XP Embedded上启动用.NET 2.0编写的服务

Ste*_*ngs 6 .net c# windows-services .net-2.0

我创建了一个小型可执行文件,可以通过调用MyApp.exe作为普通应用程序启动,也可以通过调用作为服务启动MyApp.exe -s.因为我试图保持尽可能简单,我通过手动运行"安装"此应用程序

sc create MyAppService binPath= "C:\MyApp\MyApp.exe -s"
Run Code Online (Sandbox Code Playgroud)

然后我像平常一样启动服务net start MyAppService.

在两台Windows XP计算机和两台Windows 2000计算机上,这很好用.但是,在两台不同的Windows XP Embedded机器上,当我尝试启动服务时,我收到消息:

发生系统错误1083.

配置此服务运行的可执行程序不实现该服务.

在一台机器上,我能够通过卸载并重新安装.NET 2.0来解决这个问题,但在第二台机器上,这不起作用.

我不确定如何调试这个,并且只搜索谷歌似乎只会出现这个消息失败的特定服务,如BITS和Exchange服务.

下面是类MyApp,它是启动类MyAppService,它是扩展ServiceBase的类.提前感谢任何方向.

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;
             ....
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

MyAppService.cs:

class MyAppService : ServiceBase
{
    static MyAppService()
    {
        // ...
    }

    protected override void OnStart( string[] args )
    {
        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)

nit*_*ins 1

在桌面上,如果服务未在 svchost 实例应运行的帐户下的 Windows 注册表中正确注册,则可能会发生这种情况。我没有 XPe 经验,但尝试查看 HKLM\Software\Microsoft\Windows NT\CurrentVersion\Svchost 并确保为该帐户正确列出了 MyAppService。