flamencist / flamencist/Core.System.Configuration.Install

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

未關閉
#15 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C#
星號
26
分支
12
PR 合併指標
30 天內沒有已合併 PR

描述

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;
}
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

先追蹤 InstallContext 如何解析 CreateTransactedInstaller 傳入的選項,尤其是 -assemblypath 的值以及回報的服務名稱相關失敗。使用斜線和短橫線前綴重現該行為,然後確立預期的前綴行為,並透過專案中現有的相關測試或文件涵蓋這項結果。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
csharp
領域
tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。