DO NOT SIMPLY MERGE READ DESCRIPTION - InstallUtil doesn't work with net core executables?#12232
DO NOT SIMPLY MERGE READ DESCRIPTION - InstallUtil doesn't work with net core executables?#12232AdmiralSnyder wants to merge 1 commit intodotnet:mainfrom
Conversation
…net10? net core? service executables We tried installing a service executable converted from .net framework 4.8 to net10 using installUtil, as suggested here, but that errored because of a BadImageFormatException: > Beim Initialisieren der Installation ist eine Ausnahme aufgetreten: System.BadImageFormatException: Die Datei oder Assembly "file:///D:\Publish\NexusCbfcLite\Nexus.BackgroundService.exe" oder eine Abhängigkeit davon wurde nicht gefunden. Im Modul wurde ein Assemblymanifest erwartet. i kinda expected that since ServiceUtil is a .net framework process. using `sc create` worked, though. documentation shoud reflect this (after this is cleared to be correct, of course)
|
oh. i just now realized that creating issues on this repo is possible now - so this should probably have been an issue ... well, since it's containing the change in case the question i asked turns out to be correct, i'll leave it a PR. |
There was a problem hiding this comment.
Pull request overview
This PR updates the ServiceBase documentation to replace the recommendation to use InstallUtil.exe with sc create for installing Windows services. The change addresses the fact that InstallUtil.exe is a .NET Framework tool that doesn't work with .NET Core/.NET 10 executables.
Changes:
- Replaced the reference to
InstallUtil.exewithsc createas the recommended method for installing services
| You do not have to implement <xref:System.ServiceProcess.ServiceBase.OnStart%2A>, <xref:System.ServiceProcess.ServiceBase.OnStop%2A>, or any other method in <xref:System.ServiceProcess.ServiceBase>. However, the service's behavior is described in <xref:System.ServiceProcess.ServiceBase.OnStart%2A>, so at minimum, this member should be overridden. The `main()` function of the executable registers the service in the executable with the Service Control Manager by calling the <xref:System.ServiceProcess.ServiceBase.Run%2A> method. The <xref:System.ServiceProcess.ServiceBase.ServiceName%2A> property of the <xref:System.ServiceProcess.ServiceBase> object passed to the <xref:System.ServiceProcess.ServiceBase.Run%2A> method must match the <xref:System.ServiceProcess.ServiceInstaller.ServiceName%2A> property of the service installer for that service. | ||
|
|
||
| You can use `InstallUtil.exe` to install services on your system. | ||
| You can use `sc create` to install services on your system. |
There was a problem hiding this comment.
This sentence lacks completeness for a documentation change. It should provide more context about when to use sc create versus InstallUtil.exe, particularly noting that InstallUtil.exe only works with .NET Framework applications, while sc create works with both .NET Framework and modern .NET (Core, .NET 5+). The sentence should end with a period per coding guidelines.
|
|
||
|
|
There was a problem hiding this comment.
This line contains only whitespace and should be removed. Empty lines in XML documentation should not contain trailing spaces.
| You do not have to implement <xref:System.ServiceProcess.ServiceBase.OnStart%2A>, <xref:System.ServiceProcess.ServiceBase.OnStop%2A>, or any other method in <xref:System.ServiceProcess.ServiceBase>. However, the service's behavior is described in <xref:System.ServiceProcess.ServiceBase.OnStart%2A>, so at minimum, this member should be overridden. The `main()` function of the executable registers the service in the executable with the Service Control Manager by calling the <xref:System.ServiceProcess.ServiceBase.Run%2A> method. The <xref:System.ServiceProcess.ServiceBase.ServiceName%2A> property of the <xref:System.ServiceProcess.ServiceBase> object passed to the <xref:System.ServiceProcess.ServiceBase.Run%2A> method must match the <xref:System.ServiceProcess.ServiceInstaller.ServiceName%2A> property of the service installer for that service. | ||
|
|
||
| You can use `InstallUtil.exe` to install services on your system. | ||
| You can use `sc create` to install services on your system. |
There was a problem hiding this comment.
This change is incomplete as it doesn't address the many other references to InstallUtil.exe throughout the System.ServiceProcess namespace documentation. Files like ServiceProcessInstaller.xml, ServiceInstaller.xml, and ns-System.ServiceProcess.xml still reference InstallUtil.exe. A comprehensive update should either maintain guidance for both tools (with appropriate notes about .NET Framework vs. modern .NET compatibility) or update all related documentation consistently.
| You can use `sc create` to install services on your system. | |
| You can use the `sc create` command to install services that target modern .NET, or use `InstallUtil.exe` to install services that target the .NET Framework. |
We tried installing a service executable converted from .net framework 4.8 to net10 using installUtil, as suggested here, but that errored because of a BadImageFormatException:
I kinda expected that since ServiceUtil is a .net framework process.
using
sc createworked, though. documentation shoud reflect this (after this is cleared to be correct, of course)Summary
Describe your changes here.
Fixes #Issue_Number (if available)