Question

I'm building a Windows service and following this MSDN article, but I'm stuck on step 3 under "Create an installer". I can't find the "Add Installer" link it's referring to. I've clicked everywhere, including following the instructions it gives exactly, but I can't seem to find it. A few people on Google have had the same problem, but never found a solution (other than adding the ServiceInstaller object and configuring it manually).

Has anybody else had this problem and found a reason? I'm using VS2008 and targeting .Net 2.0 if it matters.

Was it helpful?

Solution

The "Gray area" they're talking about is the Commands panel from Properties of the Properties panel (not a typo). It is not very useful so you have probably shut it off, I did.

You can either re-enable it by right-clicking the Properties panel and selecting "Commands", or add an Installer project directly by right-clicking the Service design view (the big tan window with "To add components to your class...") and selecting "Add Installer".

OTHER TIPS

For Visual Studio 2012, right click on "Services1.cs" and select "View Designer" (or press Shift-F7). Then, right click on the grey background of the designer.

Then, and only then, will you see the Easter Egg that Microsoft has been hiding from you all this time: the elusive Add Installer link.

enter link description here

To get up to date with the new visual studio express(2015) version:

It seems that we cannot have this "Add Installer" from the express edition. But it's quite simple really. You simply need to create a class and add the below code.

Also you need to add the reference System.Configuration.Install.dll.

using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;


namespace SAS
{
    [RunInstaller(true)]
    public class MyProjectInstaller : Installer
    {
        private ServiceInstaller serviceInstaller1;
        private ServiceProcessInstaller processInstaller;

        public MyProjectInstaller()
        {
            // Instantiate installer for process and service.
            processInstaller = new ServiceProcessInstaller();
            serviceInstaller1 = new ServiceInstaller();

            // The service runs under the system account.
            processInstaller.Account = ServiceAccount.LocalSystem;

            // The service is started manually.
            serviceInstaller1.StartType = ServiceStartMode.Manual;

            // ServiceName must equal those on ServiceBase derived classes.
            serviceInstaller1.ServiceName = "SAS Service";

            // Add installer to collection. Order is not important if more than one service.
            Installers.Add(serviceInstaller1);
            Installers.Add(processInstaller);
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top