安装Windows服务C#INNO自使用managedinstaller类

问题描述:

使用类似于此 Inno Setup for Windows service?安装Windows服务C#INNO自使用managedinstaller类

在Windows 7箱代码(VS 2010),当我尝试运行我的INNO安装程序我得到以下结果

与RunInstallerAttribute.Yes没有公共属性的安装程序可以找到

如果与一个标准的Windows安装程序中运行的服务的工作;这里是代码:

[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); 
     } 
    } 
} 

有没有人有这个问题的任何经验?我使用右键单击以管理员身份运行安装程序。由于

西蒙Norburn

+0

您是否尝试将“内部静态类程序”更改为“公共静态类程序”? – Gandarez

+0

是的 - 刚刚尝试过,结果相同。 exe名称没有空格,因此它不是(Q4856403)。西蒙。 – SimonN

这是一个简单的错误。 ProjectInstaller文件已损坏并从解决方案中删除。它一直打算取代它,但有人“忘了”。一旦发现问题就会自行解决。错误消息不是描述性的,也没有帮助。

问题是在你的错误信息和粘贴的代码作了明确规定。该错误指出存在“No public安装程序,并且可以找到RunInstallerAttribute.Yes属性”。在你的代码片段中,你声明你的程序类(RunInstaller属性为true)为internal

将您的类声明更改为public并且它应该正常工作。

[RunInstaller(true)] 
public static class Program 
+0

我试过了 - 它不起作用。 – SimonN

+0

当你重新编译是你的安装程序使用最新的二进制文件?你应该检查一下,以确保。另外,使用像[ILSpy](http://wiki.sharpdevelop.net/ILSpy.ashx)这样的工具来查看编译后的代码,以确保您的程序类是公开的。 – Joshua