Service C# Express

Trying to create a simple service for "educational" purposes.
Using msdn:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/vbcon/html/vbtskaddinginstallerstoyourserviceapplication.asp

To add installers to your service application

  1. In Solution Explorer, access Design view for the service for which you want to add an installation component.
  2. Click anywhere within the designer's surface.
  3. In the Description area of the Properties window, click the Add Installer link.

Where is the Description area

I have this so far:

using System;

using System.Collections.Generic;

using System.Text;

namespace Project1

{

public class UserService1 : System.ServiceProcess.ServiceBase

{

public static void Main()

{

System.ServiceProcess.ServiceBase.Run(new UserService1());

}

public UserService1()

{

this.ServiceName = "MyService1";

this.CanStop = true;

this.CanPauseAndContinue = true;

this.AutoLog = true;

}

protected override void OnStart(string[] args)

{

// Insert code here to define processing.

}

}

}




Answer this question

Service C# Express

  • Ryan Ragsdale

    Error 1 The type or namespace name 'Installer' could not be found (are you missing a using directive or an assembly reference ) C:\Documents and Settings\crowd\My Documents\Visual Studio 2005\Projects\Service\Project1\Project1\Class1.cs 7 32 Project1


  • ASIAlewis

    As a Seperate Class, Have a look at the following link as it might help...

    http://samples.gotdotnet.com/quickstart/howto/doc/simpleservice.aspx

  • Ciddire

    Dont forget to add System.Configuration.Install in your References !

    Smile


  • VH-BIL

    Should I add that code to the existing class or just add that installer class as another class.

    Where do I call class ProjectInstaller

  • M.Lipinski

    The wizards to do this are not included with the express editions, to create a windows service you will have to do it from scratch.
    Here is a small project installer class,


    using System;
    using System.Collections;
    using System.Configuration.Install;
    using System.ServiceProcess;
    using System.ComponentModel;
    [RunInstallerAttribute(true)]
    public class ProjectInstaller: Installer
    {
    private ServiceInstaller serviceInstaller;
    private ServiceProcessInstaller processInstaller;
    public ProjectInstaller()
    {
    processInstaller = new ServiceProcessInstaller();
    serviceInstaller = new ServiceInstaller();
    // Service will run under system account
    processInstaller.Account = ServiceAccount.LocalSystem;
    // Service will have Start Type of Manual
    serviceInstaller.StartType = ServiceStartMode.Manual;
    serviceInstaller.ServiceName = "Hello-World Service";
    Installers.Add(serviceInstaller);
    Installers.Add(processInstaller);
    }
    }

     




  • Service C# Express