Skip to content

Errors occur when run dotnet cli on Windows with sudo. #44576

Open
@aetos382

Description

@aetos382

Describe the bug

If I run the dotnet cli under sudo, which was added in Windows 10 24H2, an error message is displayed.

To Reproduce

sudo dotnet --info

Exceptions (if any)

System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.Installer.Windows.InstallerBase' threw an exception.
 ---> System.ArgumentException: Process with an Id of 47824 is not running.
   at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
   at Microsoft.DotNet.Installer.Windows.InstallerBase..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.DotNet.Installer.Windows.InstallerBase..ctor(InstallElevationContextBase elevationContext, ISetupLogger logger, Boolean verifySignatures)
   at Microsoft.DotNet.Installer.Windows.MsiInstallerBase..ctor(InstallElevationContextBase elevationContext, ISetupLogger logger, Boolean verifySignatures, IReporter reporter)
   at Microsoft.DotNet.Workloads.Workload.Install.NetSdkMsiInstallerClient..ctor(InstallElevationContextBase elevationContext, ISetupLogger logger, Boolean verifySignatures, IWorkloadResolver workloadResolver, SdkFeatureBand sdkFeatureBand, INuGetPackageDownloader nugetPackageDownloader, VerbosityOptions verbosity, PackageSourceLocation packageSourceLocation, IReporter reporter)
   at Microsoft.DotNet.Workloads.Workload.Install.NetSdkMsiInstallerClient.Create(Boolean verifySignatures, SdkFeatureBand sdkFeatureBand, IWorkloadResolver workloadResolver, INuGetPackageDownloader nugetPackageDownloader, VerbosityOptions verbosity, PackageSourceLocation packageSourceLocation, IReporter reporter, String tempDirPath, RestoreActionConfig restoreActionConfig, Boolean shouldLog)
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallerFactory.GetWorkloadInstaller(IReporter reporter, SdkFeatureBand sdkFeatureBand, IWorkloadResolver workloadResolver, VerbosityOptions verbosity, String userProfileDir, Boolean verifySignatures, INuGetPackageDownloader nugetPackageDownloader, String dotnetDir, String tempDirPath, PackageSourceLocation packageSourceLocation, RestoreActionConfig restoreActionConfig, Boolean elevationRequired, Boolean shouldLog)
   at Microsoft.DotNet.Workloads.Workload.List.WorkloadInfoHelper..ctor(Boolean isInteractive, VerbosityOptions verbosity, String targetSdkVersion, Nullable`1 verifySignatures, IReporter reporter, IWorkloadInstallationRecordRepository workloadRecordRepo, String currentSdkVersion, String dotnetDir, String userProfileDir, IWorkloadResolver workloadResolver)
   at Microsoft.DotNet.Cli.WorkloadCommandParser.GetWorkloadsVersion(WorkloadInfoHelper workloadInfoHelper)
   at Microsoft.DotNet.Cli.CommandLineInfo.PrintInfo()
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

Further technical details

  • Include the output of dotnet --info
.NET SDK:
 Version:           8.0.403
 Commit:            c64aa40a71
System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.Installer.Windows.InstallerBase' threw an exception.
 ---> System.ArgumentException: Process with an Id of 47824 is not running.
   at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
   at Microsoft.DotNet.Installer.Windows.InstallerBase..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.DotNet.Installer.Windows.InstallerBase..ctor(InstallElevationContextBase elevationContext, ISetupLogger logger, Boolean verifySignatures)
   at Microsoft.DotNet.Installer.Windows.MsiInstallerBase..ctor(InstallElevationContextBase elevationContext, ISetupLogger logger, Boolean verifySignatures, IReporter reporter)
   at Microsoft.DotNet.Workloads.Workload.Install.NetSdkMsiInstallerClient..ctor(InstallElevationContextBase elevationContext, ISetupLogger logger, Boolean verifySignatures, IWorkloadResolver workloadResolver, SdkFeatureBand sdkFeatureBand, INuGetPackageDownloader nugetPackageDownloader, VerbosityOptions verbosity, PackageSourceLocation packageSourceLocation, IReporter reporter)
   at Microsoft.DotNet.Workloads.Workload.Install.NetSdkMsiInstallerClient.Create(Boolean verifySignatures, SdkFeatureBand sdkFeatureBand, IWorkloadResolver workloadResolver, INuGetPackageDownloader nugetPackageDownloader, VerbosityOptions verbosity, PackageSourceLocation packageSourceLocation, IReporter reporter, String tempDirPath, RestoreActionConfig restoreActionConfig, Boolean shouldLog)
   at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallerFactory.GetWorkloadInstaller(IReporter reporter, SdkFeatureBand sdkFeatureBand, IWorkloadResolver workloadResolver, VerbosityOptions verbosity, String userProfileDir, Boolean verifySignatures, INuGetPackageDownloader nugetPackageDownloader, String dotnetDir, String tempDirPath, PackageSourceLocation packageSourceLocation, RestoreActionConfig restoreActionConfig, Boolean elevationRequired, Boolean shouldLog)
   at Microsoft.DotNet.Workloads.Workload.List.WorkloadInfoHelper..ctor(Boolean isInteractive, VerbosityOptions verbosity, String targetSdkVersion, Nullable`1 verifySignatures, IReporter reporter, IWorkloadInstallationRecordRepository workloadRecordRepo, String currentSdkVersion, String dotnetDir, String userProfileDir, IWorkloadResolver workloadResolver)
   at Microsoft.DotNet.Cli.WorkloadCommandParser.GetWorkloadsVersion(WorkloadInfoHelper workloadInfoHelper)
   at Microsoft.DotNet.Cli.CommandLineInfo.PrintInfo()
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

Host:
  Version:      8.0.10
  Architecture: x64
  Commit:       81cabf2857
  RID:          win-x64

.NET SDKs installed:
  7.0.410 [C:\Program Files\dotnet\sdk]
  8.0.403 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    • VS 2022 17.11.5
    • VS Code 1.95.1 (C# and DevKit extension is not installed)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions