Skip to content

C# Dev Kit/Roslyn LSP Fails to Activate with System.IO.IOException: The handle is invalid on Windows with .NET 10 Preview Installed #8949

@mavaddat

Description

@mavaddat

Type: Bug

Environment

  • VS Code Insiders Version: 1.109.0-insider (user setup)
    • Commit: f07c55879d2979aa0006d9cb681ca25bb7248dec
    • Date: 2026-02-03T16:58:58.241Z
    • Electron: 39.3.0
    • ElectronBuildId: 13168319
    • Chromium: 142.0.7444.265
    • Node.js: 22.21.1
    • V8: 14.2.231.22-electron.0
  • OS: Windows_NT x64 10.0.19045 (User specified win32-x64 extension path)
  • C# Extension Version: 2.114.6 (Pre-release) and 2.110.4 (Release)
  • C# Dev Kit Version: (Latest Pre-release/Release)
  • Installed .NET SDKs: 2.1, 3.1, 6.0, 7.0, 8.0.417 (Stable), 9.0
    (RC), 10.0.102 (Preview)

Relevant Extensions

  • ms-dotnettools.csdevkit@1.93.20
  • ms-dotnettools.csharp@2.114.6
  • ms-dotnettools.vscode-dotnet-runtime@3.0.0

Problem Description

The C# Dev Kit and the underlying Roslyn Language Server Protocol (LSP)
client fail to establish a connection upon activation in VS Code
Insiders. The process exits immediately with a
specific System.IO.IOException: The handle is invalid error visible in
the output logs. This occurs consistently whether using the "Release" or
"Pre-Release" channels for the extensions.
The error appears to be triggered when the .NET CLI (specifically the
preview v10.0.x or v9.0.x runtime/SDK) attempts to set console
output encoding (System.Console.set_OutputEncoding) during startup in
the non-interactive environment provided by the VS Code extension host
process.

Error Logs

The console error consistently points to a failure in console handling:

2026-02-03 18:01:31.437 [info] Locating .NET runtime version 10.0.0
2026-02-03 18:01:34.939 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2026-02-03 18:01:34.939 [info] Activating C# + C# Dev Kit...
2026-02-03 18:01:38.780 [error] [stderr] Unhandled exception. System.IO.IOException: The handle is invalid.
   at System.ConsolePal.SetConsoleOutputEncoding(Encoding enc)
   at System.Console.set_OutputEncoding(Encoding value)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

2026-02-03 18:01:38.781 [info] Language server process exited with 3762504530
2026-02-03 18:01:38.781 [error] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Language server process exited unexpectedly
	at ChildProcess.<anonymous> (c:\Users\███████████\.vscode-insiders\extensions\ms-dotnettools.csharp-2.114.6-win32-x64\dist\extension.js:942:25882)
	at ChildProcess.emit (node:events:531:35)
	at ChildProcess.emit (node:domain:489:12)
	at ChildProcess._handle.onexit (node:internal/child_process:293:12)
2026-02-03 18:04:59.378 [info] Locating .NET runtime version 10.0.0
2026-02-03 18:05:00.914 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2026-02-03 18:05:00.914 [info] Activating C# + C# Dev Kit...
2026-02-03 18:05:01.743 [error] [stderr] Unhandled exception. System.IO.IOException: The handle is invalid.
   at System.ConsolePal.SetConsoleOutputEncoding(Encoding enc)
   at System.Console.set_OutputEncoding(Encoding value)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

2026-02-03 18:05:01.743 [info] Language server process exited with 3762504530
2026-02-03 18:05:01.744 [error] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Language server process exited unexpectedly
	at ChildProcess.<anonymous> (c:\Users\███████████\.vscode-insiders\extensions\ms-dotnettools.csharp-2.114.6-win32-x64\dist\extension.js:942:25882)
	at ChildProcess.emit (node:events:531:35)
	at ChildProcess._handle.onexit (node:internal/child_process:293:12)
2026-02-03 18:10:13.866 [info] Installing C# dependencies...
2026-02-03 18:10:13.866 [info] 

2026-02-03 18:10:13.866 [info] Platform: win32, x86_64

2026-02-03 18:10:13.866 [info] 

2026-02-03 18:10:13.866 [info] Downloading package 'Language server for Roslyn Copilot integration' 
2026-02-03 18:10:15.041 [info] (47 KB)
2026-02-03 18:10:15.041 [info] .......
2026-02-03 18:10:15.042 [info] .......
2026-02-03 18:10:15.042 [info] ......
2026-02-03 18:10:15.042 [info]  Done!

2026-02-03 18:10:15.044 [info] Validating download...

2026-02-03 18:10:15.045 [info] Integrity Check succeeded.

2026-02-03 18:10:15.045 [info] Installing package 'Language server for Roslyn Copilot integration'

2026-02-03 18:10:15.045 [info] 

2026-02-03 18:10:18.624 [info] Finished

2026-02-03 18:10:18.625 [info] 

2026-02-03 18:10:18.757 [info] Locating .NET runtime version 9.0.1
2026-02-03 18:10:19.140 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2026-02-03 18:10:19.140 [info] Activating C# + C# Dev Kit...
2026-02-03 18:10:19.334 [error] [stderr] Unhandled exception. 
2026-02-03 18:10:19.394 [error] [stderr] System.IO.IOException: The handle is invalid.
   at System.ConsolePal.SetConsoleOutputEncoding(Encoding enc)
   at System.Console.set_OutputEncoding(Encoding value)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

2026-02-03 18:10:19.463 [info] Language server process exited with 3762504530
2026-02-03 18:10:19.464 [error] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Language server process exited unexpectedly
	at ChildProcess.<anonymous> (c:\Users\███████████\.vscode-insiders\extensions\ms-dotnettools.csharp-2.110.4-win32-x64\dist\extension.js:942:22265)
	at ChildProcess.emit (node:events:531:35)
	at ChildProcess._handle.onexit (node:internal/child_process:293:12)
2026-02-03 18:14:40.633 [info] Locating .NET runtime version 10.0.0
2026-02-03 18:14:43.986 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2026-02-03 18:14:43.986 [info] Activating C# + C# Dev Kit...
2026-02-03 18:14:44.899 [error] [stderr] Unhandled exception. System.IO.IOException: The handle is invalid.
   at System.ConsolePal.SetConsoleOutputEncoding(Encoding enc)
   at System.Console.set_OutputEncoding(Encoding value)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

2026-02-03 18:14:44.905 [info] Language server process exited with 3762504530
2026-02-03 18:14:44.906 [error] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Language server process exited unexpectedly
	at ChildProcess.<anonymous> (c:\Users\███████████\.vscode-insiders\extensions\ms-dotnettools.csharp-2.114.6-win32-x64\dist\extension.js:942:25882)
	at ChildProcess.emit (node:events:531:35)
	at ChildProcess._handle.onexit (node:internal/child_process:293:12)

The extension consistently logs that it is attempting to locate/use the
preview runtime:

[info] Locating .NET runtime version 10.0.0

Toast notification:

Image
Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Language server process exited unexpectedly
	at ChildProcess.<anonymous> (c:\Users\███████████\.vscode-insiders\extensions\ms-dotnettools.csharp-2.114.6-win32-x64\dist\extension.js:942:25882)
	at ChildProcess.emit (node:events:531:35)
	at ChildProcess._handle.onexit (node:internal/child_process:293:12)

Configuration (settings.json and global.json)

.vscode\settings.json:

{
  "dotnet.server.logLevel": "Trace",
  "omnisharp.sdkPath": "C:/Program Files/dotnet/sdk/8.0.417",
  "omnisharp.dotnetPath": "C:/Program Files/dotnet/dotnet.exe",
  "dotnet.server.path": "C:/Program Files/dotnet/dotnet.exe",
  "dotnet.server.useOmnisharp": false,
  "dotnetAcquisitionExtension.existingDotnetPath": [
    {
      "extensionId": "ms-dotnettools.csharp",
      "path": "C:/Program Files/dotnet/dotnet.exe"
    },
    {
      "extensionId": "ms-dotnettools.csdevkit",
      "path": "C:/Program Files/dotnet/dotnet.exe"
    }
  ],
  "dotnet.server.runtime": "8.0"
}

global.json (located in the workspace root):

{
  "sdk": {
    "version": "8.0.417",
    "rollForward": "latestFeature"
  }
}

Steps Taken (Troubleshooting attempted so far)

  1. Cleared Extension Cache: Uninstalled
    all ms-dotnettools.* extensions, manually deleted extension
    folders in %USERPROFILE%\.vscode-insiders\extensions, and
    reinstalled. This did not resolve the issue.
  2. Used stable global.json: Explicitly set the global.json SDK
    version to the stable 8.0.417 (as shown above). The extension
    still attempted to load .NET 10 and crashed.
  3. Configured Settings Overrides: Used various settings
    in settings.json (dotnet.server.runtimedotnetAcquisitionExtension.existingDotnetPath)
    to force the use of the stable .NET 8 runtime/executable. The logs
    indicate the extension activation process continues to target .NET
    10 regardless of these settings.
  4. Set Environment
    Variables:
     Set DOTNET_CLI_UI_LANGUAGE and PYTHONIOENCODING to
    bypass encoding checks, which had no effect on the outcome.
  5. Switched Extension Channels: Tested both the "Pre-Release" and
    "Release" versions of the C# extension within VS Code Insiders, both
    exhibit the same failure mode and error logs.

The underlying issue appears to be an incompatibility between the .NET
10 preview runtime's console initialization logic and the environment in
which the C# extension is launched by VS Code Insiders. The
configuration overrides intended to force a stable runtime appear to be
ignored during the initial startup phase.

Extension version: 2.114.6
VS Code version: Code - Insiders 1.109.0-insider (f07c55879d2979aa0006d9cb681ca25bb7248dec, 2026-02-03T16:58:58.241Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i5-1245U (12 x 2496)
GPU Status 2d_canvas: enabled
GPU0: VENDOR= 0x8086, DEVICE=0x4628 [Intel(R) UHD Graphics], DRIVER_VENDOR=Intel, DRIVER_VERSION=32.0.101.7080 ACTIVE
GPU1: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.19041.5794
Machine model name:
Machine model version:
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.69GB (0.87GB free)
Process Argv --crash-reporter-id 568452e6-d329-4079-9550-e01b0337ed7e
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
pythonvspyt551cf:31249598
nativeloc1:31118317
dwcopilot:31158714
dwoutputs:31242946
copilot_t_ci:31333650
g012b348:31231168
pythonrdcb7:31268811
pythonpcpt1:31399616
6518g693:31302842
6abeh943:31336334
envsactivate1:31349248
editstats-enabled:31346256
cloudbuttont:31366566
3efgi100_wstrepl:31403338
use-responses-api:31390341
je187915:31401257
none:31438490
cp_cls_t_966_ss:31454198
chatvisible:31417128
inlinechat_v2_hd992725:31445440
4je02754:31455664
ge8j1254_inline_auto_hint_haiku:31426887
a5gib710:31434435
5j92g670_sonnet:31453868
7ig2g208:31429686
406hc587_ask_agent:31428392
preserve_tokens:31444547
cp_cls_t_1081:31454832
copilot-nes-oct-trt:31432609
ia-use-proxy-models-svc:31446143
nes-slash-models-on:31441832
a43f0574:31442823
e9c30283:31453065
c0ci8992_validated:31449878
control_6dc23131:31449957
diag_5_10:31448841
nes-trig-10:31449242
idci7584:31454084
edit_mode_hidden:31453871
nes-ftch-new:31454641
nes_chat_context_enabled:31451401
showstats:31452402
e3e4d672:31454087
864ei723_large_tool_results_to_disk:31455802
pp-44cc9697:31455969
nes-fast-ctrl:31454625
ei9d7968:31455229
b1f5h706:31455228
7ef87755:31455235
nes-extended-on:31455475

Installed extensions

ahmadawais.shades-of-purple@7.3.6
alefragnani.project-manager@13.0.1
codeium.codeium@1.49.2
codezombiech.gitignore@0.10.0
davidanson.vscode-markdownlint@0.61.1
deltaxml.cals-table-viewer@0.1.0
docker.docker@0.18.0
donjayamanne.githistory@0.6.20
dotjoshjohnson.xml@2.5.1
eamodio.gitlens@17.9.0
esbenp.prettier-vscode@12.3.0
foxundermoon.shell-format@7.2.8
github.copilot-chat@0.37.2026020304
github.remotehub@0.64.0
github.vscode-github-actions@0.31.0
github.vscode-pull-request-github@0.127.2026020316
gpoore.codebraid-preview@0.17.0
james-yu.latex-workshop@10.12.2
jock.svg@1.5.4
k3ndr1ckfu.tcl-language-support-for-vscode@0.0.4
kevinrose.vsc-python-indent@1.21.0
mechatroner.rainbow-csv@3.24.1
ms-azuretools.vscode-containers@2.4.1
ms-azuretools.vscode-docker@2.0.0
ms-dotnettools.csdevkit@1.93.20
ms-dotnettools.csharp@2.114.6
ms-dotnettools.vscode-dotnet-runtime@3.0.0
ms-python.black-formatter@2025.3.11831009
ms-python.debugpy@2025.18.0
ms-python.python@2026.1.2026012801
ms-python.vscode-pylance@2025.12.102
ms-python.vscode-python-envs@1.16.0
ms-vscode-remote.remote-wsl@0.104.3
ms-vscode.cmake-tools@1.22.26
ms-vscode.cpptools@1.30.4
ms-vscode.cpptools-extension-pack@1.3.1
ms-vscode.cpptools-themes@2.0.0
ms-vscode.powershell@2025.4.0
ms-vscode.remote-repositories@0.42.0
ms-vscode.vscode-typescript-next@6.0.20260202
ms-vsliveshare.vsliveshare@1.0.5959
nextnav.nextnav@1.1.1
pharndt.node-extra-ca-certs-vscode@1.0.1
redhat.java@1.52.0
redhat.vscode-xml@0.29.0
shd101wyy.markdown-preview-enhanced@0.8.20
sidthesloth.html5-boilerplate@1.1.1
timonwong.shellcheck@0.38.6
vscjava.migrate-java-to-azure@1.11.0
vscjava.vscode-gradle@3.17.2
vscjava.vscode-java-debug@0.58.5
vscjava.vscode-java-dependency@0.27.0
vscjava.vscode-java-pack@0.30.5
vscjava.vscode-java-test@0.44.0
vscjava.vscode-java-upgrade@1.12.1
vscjava.vscode-maven@0.45.1
vsls-contrib.gistfs@0.9.6
yandeu.five-server@0.3.11
yzhang.markdown-all-in-one@3.6.3
zhiyuan-lin.simple-perl@0.0.4

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