I'm trying to host two services in a single process, and cannot get the second to 
start. The first is a simple do-nothing service, and is there to make it easy to 
attach the debugger. After setting breakpoints, I can start the second and debug it. 
The relevant parts of my service class look like this.

in myservice.cs:

static void Main()
{
        System.ServiceProcess.ServiceBase[] ServicesToRun;

        // To run the debug service, uncomment the following code line and comment out 
the
        // line that runs only the main service.
        ServicesToRun = new System.ServiceProcess.ServiceBase[] {new MyService(), new 
DebugService()};
        //ServicesToRun = new System.ServiceProcess.ServiceBase[] { new MyService() };

        System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}

private void InitializeComponent()
{
        this.ServiceName = "MyService";
}

in debugservice.cs:

private void InitializeComponent()
{
        components = new System.ComponentModel.Container();
        this.ServiceName = "DebugService";
}

and the installer has:

private void InitializeComponent()
{
        this.serviceProcessInstaller1 = new 
System.ServiceProcess.ServiceProcessInstaller();
        this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
        this.serviceInstaller2 = new System.ServiceProcess.ServiceInstaller();
        // 
        // serviceProcessInstaller1
        // 
        this.serviceProcessInstaller1.Account = 
System.ServiceProcess.ServiceAccount.LocalSystem;
        this.serviceProcessInstaller1.Password = null;
        this.serviceProcessInstaller1.Username = null;
        // 
        // serviceInstaller1
        // 
        this.serviceInstaller1.DisplayName = "Debug Service";
        this.serviceInstaller1.ServiceName = "DebugService";
        // 
        // serviceInstaller2
        // 
        this.serviceInstaller2.DisplayName = "MyService";
        this.serviceInstaller2.ServiceName = "MyService";
        // 
        // ProjectInstaller
        // 
        this.Installers.AddRange(new System.Configuration.Install.Installer[] {
                this.serviceProcessInstaller1,
                this.serviceInstaller1,
                this.serviceInstaller2});
}

The installation works. The debug service can be started. When I try to start the 
other service, I get

"Could not start the MyService service on Local Computer.
 Error 1083: The executable program that this service is configured to run in does not 
implement the service."


This is the error I would expect to see if the ServiceName property of the service 
does not match the ServiceInstaller's ServiceName property, but they DO match? Can 
someone tell me what I'm doing wrong?

David

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to