简体   繁体   English

使用ManagedInstaller类安装Windows Service C#Inno Self

[英]Installing Windows service C# inno self using managedinstaller class

using code similar to this Inno Setup for Windows service? 使用类似于此Inno Setup for Windows服务的代码?

on a windows 7 box (VS 2010) when I try to run my inno installer I get the following result 在Windows 7盒(VS 2010)上,当我尝试运行Inno安装程序时,得到以下结果

No public installers with the RunInstallerAttribute.Yes attribute could be found 找不到带有RunInstallerAttribute.Yes属性的公共安装程序

The service works if run with a standard windows installer; 如果与标准Windows安装程序一起运行,则该服务有效; 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". 该错误指出“没有找到具有RunInstallerAttribute.Yes属性的公共安装程序”。 In your code snippet you declare your Program class (with the RunInstaller attribute to true) as internal . 在代码段中,将Program类(将RunInstaller属性设置为true)声明为internal

Change your class declaration to public and it should work correctly. 将您的类声明更改为public,它应该可以正常工作。

[RunInstaller(true)]
public static class Program

This was a simple error. 这是一个简单的错误。 The ProjectInstaller file had become corrupt and removed from the solution. ProjectInstaller文件已损坏,并已从解决方案中删除。 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. 该错误消息不是描述性的,也没有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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