flamencist / flamencist/Core.System.Configuration.Install
"Cannot get service name" because options for InstallContext need '-' prefix, not '/'.
- Vorherrschende Sprache
- C#
- Sterne
- 26
- Forks
- 12
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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;
}
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne damit nachzuverfolgen, wie InstallContext die von CreateTransactedInstaller übergebenen Optionen verarbeitet, insbesondere den Wert von -assemblypath und den gemeldeten Fehler beim Dienstnamen. Reproduziere das Verhalten mit den Präfixen für Schrägstrich und Bindestrich, ermittle anschließend das beabsichtigte Präfixverhalten und decke das Ergebnis mit dem entsprechenden im Projekt verfügbaren Test oder der entsprechenden Dokumentation ab.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100