Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to start service written in .NET 2.0 on Windows XP Embedded

I've created a small executable that can be launched either as a normal application by calling MyApp.exe or as a service by calling MyApp.exe -s. Because I'm trying to keep as simple as possible, I "install" this app by manually running

sc create MyAppService binPath= "C:\MyApp\MyApp.exe -s"

Then I start the service with net start MyAppService like normal.

On two Windows XP machines and two Windows 2000 machines, this works fine. However, on two different Windows XP Embedded machines, when I try to start the service I get the message:

System error 1083 has occurred.

The executable program that this service is configured to run in does not implement the service.

On one machine, I was able to fix this by uninstalling and reinstalling .NET 2.0, but on the second machine this did not work.

I'm not sure how to go about debugging this, and searching google only seems to turn up specific services that fail with this message such as BITS and an Exchange service.

Below are the classes MyApp, which is the startup class, and MyAppService, which is the class that extends ServiceBase. Thanks in advance for any direction on this.

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 )
    {
        // ...
    }
}
like image 943
Stephen Jennings Avatar asked Mar 09 '10 22:03

Stephen Jennings


1 Answers

On the desktop, this can happen if the service isn't registered correctly in the Windows Registry under the account that the svchost instance is supposed to run under. I don't have experience in XPe, but try looking in HKLM\Software\Microsoft\Windows NT\CurrentVersion\Svchost and make sure that MyAppService is correctly listed for the account.

like image 179
nithins Avatar answered Oct 21 '22 23:10

nithins