Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
安装Windows服务C#inno自用managedinstaller类_C#_Windows_Service - Fatal编程技术网

安装Windows服务C#inno自用managedinstaller类

安装Windows服务C#inno自用managedinstaller类,c#,windows,service,C#,Windows,Service,使用与此类似的代码 在Windows7上(VS2010),当我尝试运行inno安装程序时,我得到以下结果 找不到具有RunInstallerAttribute.Yes属性的公共安装程序 如果使用标准windows安装程序运行,该服务将正常工作;代码如下: [RunInstaller(true)] internal static class Program { /// <summary> /// The main entry point for the applica

使用与此类似的代码

在Windows7上(VS2010),当我尝试运行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);
        }
    }
}
[运行安装程序(true)]
内部静态类程序
{
/// 
///应用程序的主要入口点。
/// 
公共静态void Main(字符串[]args)
{
如果(args.Count()==1)
{
字符串参数=string.Concat(args);
开关(参数)
{
案例”--安装:
ManagedInstallerClass.InstallHelper(新字符串[]{Assembly.GetExecutionGassembly().Location});
打破
案例”--卸载:
ManagedInstallerClass.InstallHelper(新字符串[])
{“/u”,Assembly.getExecutionGassembly().Location});
打破
}
}
其他的
{
ServiceBase[]ServicesToRun;
ServicesToRun=新的ServiceBase[]
{
新天文学
};
ServiceBase.Run(ServicesToRun);
}
}
}
有没有人有过这方面的经验?我使用右键单击以管理员身份运行安装程序。谢谢


Simon Norburn在错误消息和粘贴的代码中清楚地说明了问题。错误表明“没有具有RunInstallerAttribute.Yes属性的公共安装程序”。在代码段中,您将程序类(RunInstaller属性为true)声明为internal

将类声明更改为public,它应该可以正常工作

[RunInstaller(true)]
public static class Program

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

是否尝试将“内部静态类程序”更改为“公共静态类程序”?是-只是再次尝试,结果相同。exe名称没有空格,因此也不是空格(Q4856403)。当你重新编译时,你的安装程序使用的是最新的二进制文件吗?你应该检查一下以确定。另外,使用类似于查看编译代码的工具来确保您的程序类是公共的。