开发者

Installing Windows service C# inno self using managedinstaller class

开发者 https://www.devze.com 2023-03-30 08:01 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消