Visual Studio missing “Add Installer” link in service project

后端 未结 3 618
我寻月下人不归
我寻月下人不归 2021-01-18 09:39

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 refer

相关标签:
3条回答
  • 2021-01-18 10:08

    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".

    0 讨论(0)
  • 2021-01-18 10:13

    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

    0 讨论(0)
  • 2021-01-18 10:17

    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);
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题