dotnet / dotnet/vscode-csharp

C# Extension Crashes When Saving New File Created via ".NET New File" in VS Code

Open
#8,675 4 comments 0 reactions 0 assignees View on GitHub
untriaged
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

Type: Bug

## Issue Description ##
Whenever I create a new file in Visual Studio Code using the ".NET New File" command and attempt to save it, the C# extension crashes. The output window shows repeated errors such as "Failed to get language for textDocument/diagnostic" and "Document pull failed for text document untitled:Untitled-1". This issue occurs consistently and prevents saving new files created through the ".NET New File" workflow.

## Steps to Reproduce ##
1. Create a new file in VS Code using the ".NET New File" command
2. Try to save the file
3. Observe that C# crashes with the error above

## Expected Behavior ##
The file should be saved without crashing the C# extension.

## Actual Behavior ##
C# crashes with the error message above when saving a new file created via ".NET New File".

Image

Extension version: 2.90.60
VS Code version: Code 1.104.2 (e3a5acfb517a443235981655413d566533107e92, 2025-09-24T11:21:37.073Z)
OS version: Darwin arm64 24.6.0
Modes:

### Logs ###

### C# log ###

```
2025-10-02 11:37:36.318 [info] Locating .NET runtime version 9.0.1
2025-10-02 11:37:36.377 [info] Dotnet path: /usr/local/share/dotnet/dotnet
2025-10-02 11:37:36.377 [info] Activating C# + C# Dev Kit...
2025-10-02 11:37:36.454 [info] [stdout] info: Program[0]
Server started with process ID 3563

2025-10-02 11:37:36.708 [info] [stdout] {"pipeName":"/var/folders/lc/nf0p2stx0rld6r95vd22s28h0000gn/T/7403409d.sock"}

2025-10-02 11:37:36.708 [info] received named pipe information from server
2025-10-02 11:37:36.709 [info] client has connected to server
2025-10-02 11:37:36.762 [info] [Program] Language server initialized
2025-10-02 11:37:39.764 [info] [textDocument/diagnostic] [Microsoft.CodeAnalysis.LanguageServer.DotnetCliHelper] Using dotnet executable configured on the PATH
2025-10-02 11:37:39.769 [info] [textDocument/diagnostic] [Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.FileBasedProgramsProjectSystem] Failed to obtain virtual project for '/Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/src/WebShop.Api/Contracts/Products/test.cs' using dotnet run-api. Falling back to directly creating the virtual project.
2025-10-02 11:37:39.788 [warning] [textDocument/diagnostic] [LanguageServerProjectLoader] Project /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/src/WebShop.Api/Contracts/Products/test.csproj has unresolved dependencies
2025-10-02 11:37:39.793 [info] [textDocument/diagnostic] [LanguageServerProjectLoader] Successfully completed load of /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/src/WebShop.Api/Contracts/Products/test.cs
2025-10-02 11:37:40.134 [error] [workspace/_roslyn_restore] [Microsoft.CodeAnalysis.LanguageServer.Handler.RestoreHandler] Restore completed with errors.
2025-10-02 11:37:40.146 [info] [textDocument/diagnostic] [LanguageServerProjectLoader] Completed (re)load of all projects in 00:00:01.1999756
2025-10-02 11:37:41.971 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/src/WebShop.Infrastructure/WebShop.Infrastructure.csproj loaded by C# Dev Kit
2025-10-02 11:37:41.978 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/tests/WebShop.Api.Tests/WebShop.Api.Tests.csproj loaded by C# Dev Kit
2025-10-02 11:37:41.982 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/tests/WebShop.Integration.Tests/WebShop.Integration.Tests.csproj loaded by C# Dev Kit
2025-10-02 11:37:41.982 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/src/WebShop.Api/WebShop.Api.csproj loaded by C# Dev Kit
2025-10-02 11:37:41.984 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/src/WebShop.Domain/WebShop.Domain.csproj loaded by C# Dev Kit
2025-10-02 11:37:41.984 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/src/WebShop.Application/WebShop.Application.csproj loaded by C# Dev Kit
2025-10-02 11:37:41.985 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project /Users/florestankorp/Documents/Coding/WEBDEV/dotnet/Webshop/tests/WebShop.Unit.Tests/WebShop.Unit.Tests.csproj loaded by C# Dev Kit
2025-10-02 11:38:50.885 [error] [textDocument/diagnostic] [LSP] Failed to get language for untitled:Untitled-1 with language
2025-10-02 11:38:50.887 [error] [textDocument/diagnostic] [LSP] System.Exception: Failed to get language for textDocument/diagnostic
2025-10-02 11:38:50.891 [error] Request textDocument/diagnostic failed.
Message: Failed to get language for textDocument/diagnostic
Code: -32000
[object Object]
2025-10-02 11:38:50.891 [error] Document pull failed for text document untitled:Untitled-1
Message: Failed to get language for textDocument/diagnostic
Code: -32000
[object Object]

```

### C# LSP Trace Logs log ###

```

```

## Environment Information ##
**VSCode version**: 1.104.2
**C# Extension**: 2.90.60
**Using OmniSharp**: false

Dotnet Information
.NET SDK:
Version: 9.0.301
Commit: a596cd22e2
Workload version: 9.0.300-manifests.9bcbba73
MSBuild version: 17.14.5+edd3bbf37

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.6
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.301/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.6
Architecture: arm64
Commit: 3875b54e7b

.NET SDKs installed:
9.0.301 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

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

Download .NET:
https://aka.ms/dotnet/download

Visual Studio Code Extensions

|Extension|Author|Version|Folder Name|
|---|---|---|---|
|angular-console|nrwl|18.70.0|nrwl.angular-console-18.70.0|
|angular-essentials|johnpapa|18.0.0|johnpapa.angular-essentials-18.0.0|
|Angular2|johnpapa|18.0.2|johnpapa.angular2-18.0.2|
|astro-vscode|astro-build|2.15.4|astro-build.astro-vscode-2.15.4-darwin-arm64|
|auto-close-tag|formulahendry|0.5.15|formulahendry.auto-close-tag-0.5.15|
|auto-complete-tag|formulahendry|0.1.0|formulahendry.auto-complete-tag-0.1.0|
|code-spell-checker|streetsidesoftware|4.2.6|streetsidesoftware.code-spell-checker-4.2.6|
|code-spell-checker-dutch|streetsidesoftware|0.5.4|streetsidesoftware.code-spell-checker-dutch-0.5.4|
|copilot|GitHub|1.372.0|github.copilot-1.372.0|
|copilot-chat|GitHub|0.31.3|github.copilot-chat-0.31.3|
|cpptools|ms-vscode|1.27.7|ms-vscode.cpptools-1.27.7-darwin-arm64|
|csdevkit|ms-dotnettools|1.50.51|ms-dotnettools.csdevkit-1.50.51-darwin-arm64|
|csharp|ms-dotnettools|2.90.60|ms-dotnettools.csharp-2.90.60-darwin-arm64|
|data-workspace-vscode|ms-mssql|0.6.3|ms-mssql.data-workspace-vscode-0.6.3|
|docker|docker|0.17.0|docker.docker-0.17.0-darwin-arm64|
|dupchecker|jianbingfang|0.1.7|jianbingfang.dupchecker-0.1.7|
|EditorConfig|EditorConfig|0.17.4|editorconfig.editorconfig-0.17.4|
|errorlens|usernamehw|3.26.0|usernamehw.errorlens-3.26.0|
|explorer|vitest|1.30.0|vitest.explorer-1.30.0|
|gc-excelviewer|GrapeCity|4.2.64|grapecity.gc-excelviewer-4.2.64|
|gitlens|eamodio|17.5.1|eamodio.gitlens-17.5.1|
|go|golang|0.50.0|golang.go-0.50.0|
|grafana-alloy|Grafana|0.2.0|grafana.grafana-alloy-0.2.0|
|hexeditor|ms-vscode|1.11.1|ms-vscode.hexeditor-1.11.1|
|html-css-class-completion|Zignd|1.20.0|zignd.html-css-class-completion-1.20.0|
|LiveServer|ritwickdey|5.7.9|ritwickdey.liveserver-5.7.9|
|material-icon-theme|PKief|5.27.0|pkief.material-icon-theme-5.27.0|
|ng-template|Angular|20.2.2|angular.ng-template-20.2.2|
|output-colorizer|IBM|0.1.2|ibm.output-colorizer-0.1.2|
|playwright|ms-playwright|1.1.15|ms-playwright.playwright-1.1.15|
|prettier-vscode|esbenp|11.0.0|esbenp.prettier-vscode-11.0.0|
|pretty-ts-errors|YoavBls|0.6.1|yoavbls.pretty-ts-errors-0.6.1|
|properties-validator|vivek-kasture|0.0.6|vivek-kasture.properties-validator-0.0.6|
|rainbow-csv|mechatroner|3.22.0|mechatroner.rainbow-csv-3.22.0|
|remote-containers|ms-vscode-remote|0.429.0|ms-vscode-remote.remote-containers-0.429.0|
|remote-explorer|ms-vscode|0.5.0|ms-vscode.remote-explorer-0.5.0|
|remote-server|ms-vscode|1.5.3|ms-vscode.remote-server-1.5.3|
|remote-ssh|ms-vscode-remote|0.120.0|ms-vscode-remote.remote-ssh-0.120.0|
|remote-ssh-edit|ms-vscode-remote|0.87.0|ms-vscode-remote.remote-ssh-edit-0.87.0|
|remote-wsl|ms-vscode-remote|0.104.3|ms-vscode-remote.remote-wsl-0.104.3|
|sonarlint-vscode|SonarSource|4.31.0|sonarsource.sonarlint-vscode-4.31.0-darwin-arm64|
|svelte-vscode|svelte|109.11.1|svelte.svelte-vscode-109.11.1|
|terraform|hashicorp|2.37.2|hashicorp.terraform-2.37.2-darwin-arm64|
|vscode-azureappservice|ms-azuretools|0.26.4|ms-azuretools.vscode-azureappservice-0.26.4|
|vscode-azureresourcegroups|ms-azuretools|0.11.4|ms-azuretools.vscode-azureresourcegroups-0.11.4|
|vscode-containers|ms-azuretools|2.2.0|ms-azuretools.vscode-containers-2.2.0|
|vscode-counter|uctakeoff|3.7.2|uctakeoff.vscode-counter-3.7.2|
|vscode-css-formatter|aeschli|1.0.2|aeschli.vscode-css-formatter-1.0.2|
|vscode-diff|fabiospampinato|2.1.2|fabiospampinato.vscode-diff-2.1.2|
|vscode-docker|ms-azuretools|2.0.0|ms-azuretools.vscode-docker-2.0.0|
|vscode-dotnet-runtime|ms-dotnettools|2.3.7|ms-dotnettools.vscode-dotnet-runtime-2.3.7|
|vscode-eslint|dbaeumer|3.0.16|dbaeumer.vscode-eslint-3.0.16|
|vscode-github-actions|github|0.27.2|github.vscode-github-actions-0.27.2|
|vscode-icons|vscode-icons-team|12.14.0|vscode-icons-team.vscode-icons-12.14.0|
|vscode-jest|Orta|6.4.4|orta.vscode-jest-6.4.4|
|vscode-jest-runner|firsttris|0.4.84|firsttris.vscode-jest-runner-0.4.84|
|vscode-pylance|ms-python|2025.8.3|ms-python.vscode-pylance-2025.8.3|
|vscode-remote-extensionpack|ms-vscode-remote|0.26.0|ms-vscode-remote.vscode-remote-extensionpack-0.26.0|
|vscode-speech|ms-vscode|0.16.0|ms-vscode.vscode-speech-0.16.0-darwin-arm64|
|vscode-sqlite|alexcvzz|0.14.1|alexcvzz.vscode-sqlite-0.14.1|
|vscode-stylelint|stylelint|1.5.3|stylelint.vscode-stylelint-1.5.3|
|vscode-svgviewer|cssho|2.0.0|cssho.vscode-svgviewer-2.0.0|
|vscode-tailwindcss|bradlc|0.14.26|bradlc.vscode-tailwindcss-0.14.26|
|vscode-xml|redhat|0.29.0|redhat.vscode-xml-0.29.0-darwin-arm64|
|vscode-yaml|redhat|1.19.0|redhat.vscode-yaml-1.19.0|;

C# Settings

|Setting|Value|
|---|---|
|preferCSharpExtension|false|
|compilerDiagnosticScope|openFiles|
|analyzerDiagnosticScope|openFiles|
|enableXamlTools|true|
|useServerGC|true|;

System Info

|Item|Value|
|---|---|
|CPUs|Apple M2 Pro (10 x 2400)|
|GPU Status|2d_canvas: enabled
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: enabled_on
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off|
|Load (avg)|3, 6, 6|
|Memory (System)|16.00GB (0.31GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.