简体   繁体   中英

Installing Windows service C# inno self using managedinstaller class

using code similar to this Inno Setup for Windows service?

on a windows 7 box (VS 2010) when I try to run my inno installer I get the following result

No public installers with the RunInstallerAttribute.Yes attribute could be found

The service works if run with a standard windows installer; here is the code:

[RunInstaller(true)]
internal static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    public static void Main(string[] args)
    {
        if (args.Count()==1)
        {
            string parameter = string.Concat(args);
            switch (parameter)
            {
                case "--install":
                    ManagedInstallerClass.InstallHelper(new string[] {Assembly.GetExecutingAssembly().Location});
                    break;
                case "--uninstall":
                    ManagedInstallerClass.InstallHelper(new string[]
                                                            {"/u", Assembly.GetExecutingAssembly().Location});
                    break;
            }
        }
        else
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
                                {
                                    new SkyLibrarian()
                                };
            ServiceBase.Run(ServicesToRun);
        }
    }
}

Does anyone have any experience of this issue? I run the installer as an administrator using a right click. Thanks

Simon Norburn

The problem is clearly stated in your error message and your pasted code. The error states that there is "No public installers with the RunInstallerAttribute.Yes attribute could be found". In your code snippet you declare your Program class (with the RunInstaller attribute to true) as internal .

Change your class declaration to public and it should work correctly.

[RunInstaller(true)]
public static class Program

This was a simple error. The ProjectInstaller file had become corrupt and removed from the solution. It had been intended to replace it but someone 'forgot'. Once that was found the issue resolved itself. The error message was not descriptive nor helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM