"Cannot get service name" because options for InstallContext need '-' prefix, not '/'.

未关闭
#15 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp
领域
tooling

调研方向

先追踪 InstallContext 如何解析 CreateTransactedInstaller 传入的选项,尤其是 -assemblypath 的值以及报告的服务名称相关失败。使用斜杠和短横线前缀重现该行为,然后确定预期的前缀行为,并通过项目中现有的相关测试或文档覆盖这一结果。

由索引模型根据 Issue 内容生成。

描述

I just ported some software from .NET FrameWork to .NET Core and gratefully used this Nuget package to allow it to install itself as Windows service. I wanted to minimize the amount of work so I didn't want to re-architect my service to the new Worker Service architecture, at least for now.

That didn't work: the install failed with "Cannot get service name" and then rolled back.

It turns out that the problem was that I used a slash '/' instead of a dash '-'.

I don't know if the slash was officially supported in the .NET FrameWork code; the code I'm working on was based on some sample code on the Internet about 10 years ago. So I don't know if I should request that '/' be an alternate prefix character to '-'. I just wanted to post this as an issue because it took me a long time to figure this out, and maybe this is useful for others who run into the same situation.

Fragment of my code after correcting the problem:

        private static TransactedInstaller CreateTransactedInstaller(Type T)
        {
            TransactedInstaller result = new TransactedInstaller();

            // NOTE: the path option must start with '-', not '/'. The path must be the .exe file, not a .dll file.
            string path = "-assemblypath=" + System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;

            result.Installers.Add(new InstallerConsoleModule(T, null)); // Constructor checks the type
            result.Context = new InstallContext(null, new[] { path });

            return result;
        }
主要语言
C#
星标
26
派生
12
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

flamencist/Core.System.Configuration.Install 的其他 Issue

查看 flamencist/Core.System.Configuration.Install 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。