Skip to content

Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers.IsWindowsService crashes when started as service #67093

@schuettecarsten

Description

@schuettecarsten

Description

IsWindowsService fails when an App is started as a service from services.msc MMC plugin.

 ---> System.InvalidOperationException: Process has exited, so the requested information is not available.
   at System.Diagnostics.Process.get_ProcessName()
   at Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers.IsWindowsService()

Reproduction Steps

Create an executable, call Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers.IsWindowsService() and register this app as a Windows Service. Start this service from the services.msc MMC plugin. It will fail.

Expected behavior

Should work and return true or false...

Actual behavior

Exception

Regression?

Yes, worked with preview.1

Known Workarounds

No workaround.

Configuration

CoreCLR Version: 7.0.22.15202
.NET Version: 7.0.0-preview.2.22152.2

Other information

CoreCLR Version: 7.0.22.15202
.NET Version: 7.0.0-preview.2.22152.2

---> System.InvalidOperationException: Process has exited, so the requested information is not available.
at System.Diagnostics.Process.get_ProcessName()
at Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers.IsWindowsService()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions