C# 如何为windows服务使用inno安装程序

C# 如何为windows服务使用inno安装程序,c#,.net,windows-services,inno-setup,C#,.net,Windows Services,Inno Setup,问题1449994解决了我的问题,但我不知道将示例代码放在哪里: static void Main(string[] args) { if (System.Environment.UserInteractive) { string parameter = string.Concat(args); switch (parameter) { case "--install": Ma

问题1449994解决了我的问题,但我不知道将示例代码放在哪里:

static void Main(string[] args)
{
    if (System.Environment.UserInteractive)
    {
        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.Run(new WindowsService());
    }
}

服务应用程序没有Main方法,那么这段代码去了哪里?我试着把它放在OnStart之前,但它无法生成。

请用SO编辑器上的“代码”按钮将代码格式化为代码,好吗?如果你看不懂,没有人会帮你。你为什么说Windows服务没有
Main
方法?我见过的每个人都有。您想从您的服务运行安装程序,还是使用InnoSetup安装您的服务?