runtime: Failed to read environment variable [DOTNET_STARTUP_HOOKS], HRESULT: 0x800700CB

Description

in vs17.6.3,the following error message is displayed in eventvwr

Description: A .NET application failed.
Application: ServiceHub.IndexingService.exe
Path: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\ServiceHub\Hosts\ServiceHub.Host.Dotnet.x64\ServiceHub.IndexingService.exe
Message: Failed to read environment variable [DOTNET_STARTUP_HOOKS], HRESULT: 0x800700CB
Description: A .NET application failed.
Application: ServiceHub.DataWarehouseHost.exe
Path: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\ServiceHub\Hosts\ServiceHub.Host.Dotnet.x64\ServiceHub.DataWarehouseHost.exe
Message: Failed to read environment variable [DOTNET_STARTUP_HOOKS], HRESULT: 0x800700CB
Description: A .NET application failed.
Application: ServiceHub.IndexingService.exe
Path: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\ServiceHub\Hosts\ServiceHub.Host.Dotnet.x64\ServiceHub.IndexingService.exe
Message: Failed to read environment variable [DOTNET_STARTUP_HOOKS], HRESULT: 0x800700CB

Reproduction Steps

Currently every launch of vs triggers this error.

Expected behavior

no error

Actual behavior

something went wrong

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK:
 Version:   8.0.100-preview.6.23316.2
 Commit:    5071f1f4ed

 OS Name:     Windows
 OS Version:  10.0.25393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-preview.6.23316.2\

Host:
  Version:      8.0.0-preview.6.23315.6
  Architecture: x64
  Commit:       35a5afb63f

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 15 (9 by maintainers)

Most upvoted comments

I couldn’t start my executable from Visual Studio due to this issue. I could see this environment variable having an empty value using process explorer, but like others I did not set it. I had just upgraded from 17.6.4 to 17.6.5 which updated my .net 7 install from 7.0.7 to 7.0.9 when the error started.

Searching on DOTNET_STARTUP_HOOKS within Visual Studio’s install location, I got a hit in C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\servicehub.config.json. This was being set to an empty string there:

{
  "$schema": "../../schemas/servicehub.config.schema.json",
  "controller": {
    "args": [ "$PIPE" ],
    "executable": "./ServiceHub/controller/Microsoft.ServiceHub.Controller.exe",
    "contextEnvironmentVariables": [ "VSAPPIDDIR", "VSAPPIDNAME", "VSROOTSUFFIX" ],
    "additionalEnvironmentVariables": { 
      "NODE_OPTIONS": "",
      "COMPLUS_FusionEnableForcedFullClosureWalk": "1",
      "DOTNET_STARTUP_HOOKS": "",
      "COMPlus_ThreadPool_UsePortableThreadPool": "0"
    },
    "dotnetRoot": "../dotnet/runtime"
  },
  "hosts": {
    "rootDir": "./ServiceHub/Hosts",
    "appConfigFallback": "devenv.exe.config"
  },
  "services": {
    "rootDir": "./ServiceHub/Services",
    "discoveryServices": [ "VsixServiceDiscovery", "VsixServiceDiscovery.x86" ]
  }
}

Removing it from additionalEnvironmentVariables should also resolve the issue for others until this fix filters through as an update. I did restart the machine to ensure this new config was applied correctly.

I agree - I think we should propose backporting.