C# is almost unusable

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

The language server crashes pretty much every time the agent makes a change.

You get pop up errors;
Client Microsoft.CodeAnalysis.LanguageServer: connection to server is erroring. write EOF Shutting down server.
Client Microsoft.CodeAnalysis.LanguageServer: connection to server is erroring. write EOF

And in the output window

2026-03-23 16:18:50.312 [info] [Error - 4:18:50 PM] [textDocument/didOpen] [LanguageServerHost] System.InvalidOperationException: didOpen received for file:///f:/sbox/shoothouse/code/Game/Items/ItemInstance.cs which is already open. - file LspWorkspaceManager.cs line 159
   at Microsoft.CodeAnalysis.Contract.Fail(String message, Int32 lineNumber, String filePath) in /_/src/Dependencies/Contracts/Contract.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.LspWorkspaceManager.StartTrackingAsync(Uri uri, SourceText documentText, String languageId, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidOpenHandler.HandleNotificationAsync(DidOpenTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidOpenHandler.cs:line 41
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 203
2026-03-23 16:18:50.313 [info] [Error - 4:18:50 PM] [LanguageServerHost] System.InvalidOperationException: didOpen received for file:///f:/sbox/shoothouse/code/Game/Items/ItemInstance.cs which is already open. - file LspWorkspaceManager.cs line 159
   at Microsoft.CodeAnalysis.Contract.Fail(String message, Int32 lineNumber, String filePath) in /_/src/Dependencies/Contracts/Contract.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.LspWorkspaceManager.StartTrackingAsync(Uri uri, SourceText documentText, String languageId, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidOpenHandler.HandleNotificationAsync(DidOpenTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidOpenHandler.cs:line 41
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 203
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 246
   at Microsoft.CodeAnalysis.LanguageServer.RoslynRequestExecutionQueue.WrapStartRequestTaskAsync(Task requestTask, Boolean rethrowExceptions) in /_/src/LanguageServer/Protocol/RoslynRequestExecutionQueue.cs:line 32
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueCoreAsync[TRequest,TResponse](IQueueItem`1 work, IMethodHandler handler, RequestHandlerMetadata metadata, ConcurrentDictionary`2 concurrentlyExecutingTasks, CancellationTokenSource currentWorkCts, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 367
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.InvokeProcessCoreAsync(IQueueItem`1 work, RequestHandlerMetadata metadata, IMethodHandler handler, MethodInfo methodInfo, ConcurrentDictionary`2 concurrentlyExecutingTasks, CancellationTokenSource currentWorkCts, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 320
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueAsync() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 272
2026-03-23 16:18:50.314 [info] [Info  - 4:18:50 PM] Error processing queue, shutting down
2026-03-23 16:18:50.320 [info] [Info  - 4:18:50 PM] Connection to server got closed. Server will restart.
2026-03-23 16:18:50.320 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2026-03-23 16:18:50.320 [info] Activating C# standalone...
2026-03-23 16:18:50.386 [info] Language server process exited with 0
2026-03-23 16:18:50.485 [info] [stdout] fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\.razorExtension\Microsoft.VisualStudioCode.RazorExtension.dll with assembly name Microsoft.VisualStudioCode.RazorExtension, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 conflicts with extension loaded from c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\.razorExtension

2026-03-23 16:18:50.770 [info] [stdout] {"pipeName":"\\\\.\\pipe\\dc4a9bde"}

2026-03-23 16:18:50.770 [info] received named pipe information from server
2026-03-23 16:18:50.771 [info] client has connected to server
2026-03-23 16:18:50.830 [info] [Info  - 4:18:50 PM] [Program] Language server initialized
2026-03-23 16:18:51.071 [info] [Info  - 4:18:51 PM] [solution/open] [LanguageServerProjectSystem] Loading f:\sbox\shoothouse\shoothouse.sln...
2026-03-23 16:18:51.080 [info] [Error - 4:18:51 PM] [textDocument/didOpen] [LanguageServerHost] System.InvalidOperationException: didOpen received for file:///f:/sbox/shoothouse/code/Game/Items/ItemInstance.cs which is already open. - file LspWorkspaceManager.cs line 159
   at Microsoft.CodeAnalysis.Contract.Fail(String message, Int32 lineNumber, String filePath) in /_/src/Dependencies/Contracts/Contract.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.LspWorkspaceManager.StartTrackingAsync(Uri uri, SourceText documentText, String languageId, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidOpenHandler.HandleNotificationAsync(DidOpenTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidOpenHandler.cs:line 41
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 203
2026-03-23 16:18:51.082 [info] [Error - 4:18:51 PM] [LanguageServerHost] System.InvalidOperationException: didOpen received for file:///f:/sbox/shoothouse/code/Game/Items/ItemInstance.cs which is already open. - file LspWorkspaceManager.cs line 159
   at Microsoft.CodeAnalysis.Contract.Fail(String message, Int32 lineNumber, String filePath) in /_/src/Dependencies/Contracts/Contract.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.LspWorkspaceManager.StartTrackingAsync(Uri uri, SourceText documentText, String languageId, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidOpenHandler.HandleNotificationAsync(DidOpenTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidOpenHandler.cs:line 41
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 203
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 246
   at Microsoft.CodeAnalysis.LanguageServer.RoslynRequestExecutionQueue.WrapStartRequestTaskAsync(Task requestTask, Boolean rethrowExceptions) in /_/src/LanguageServer/Protocol/RoslynRequestExecutionQueue.cs:line 32
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueCoreAsync[TRequest,TResponse](IQueueItem`1 work, IMethodHandler handler, RequestHandlerMetadata metadata, ConcurrentDictionary`2 concurrentlyExecutingTasks, CancellationTokenSource currentWorkCts, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 367
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.InvokeProcessCoreAsync(IQueueItem`1 work, RequestHandlerMetadata metadata, IMethodHandler handler, MethodInfo methodInfo, ConcurrentDictionary`2 concurrentlyExecutingTasks, CancellationTokenSource currentWorkCts, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 320
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueAsync() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 272
2026-03-23 16:18:51.083 [info] [Info  - 4:18:51 PM] Error processing queue, shutting down
2026-03-23 16:18:51.084 [info] [Error - 4:18:51 PM] Workspace diagnostic pull failed.
2026-03-23 16:18:51.084 [info] Canceled: Canceled
	at l4.handleFailedRequest (c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:89:9256)
	at l4.handleFailedRequest (c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:1227:870)
	at c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:83:12419
	at runNextTicks (node:internal/process/task_queues:64:5)
	at process.processImmediate (node:internal/timers:452:9)
	at process.callbackTrampoline (node:internal/async_hooks:130:17)
	at async Object.z$ [as provideWorkspaceDiagnostics] (c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:1221:5524)
	at async kJ.pullWorkspaceAsync (c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:83:9721)
2026-03-23 16:18:51.085 [info] [Error - 4:18:51 PM] Workspace diagnostic pull failed.
2026-03-23 16:18:51.085 [info] Canceled: Canceled
	at l4.handleFailedRequest (c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:89:9256)
	at l4.handleFailedRequest (c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:1227:870)
	at c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:83:12419
	at async Object.z$ [as provideWorkspaceDiagnostics] (c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:1221:5524)
	at async kJ.pullWorkspaceAsync (c:\Users\remsc\.cursor\extensions\anysphere.csharp-1.0.1-win32-x64\dist\extension.js:83:9721)
2026-03-23 16:18:51.087 [info] [Error - 4:18:51 PM] Client Microsoft.CodeAnalysis.LanguageServer: connection to server is erroring.
write EOF
Shutting down server.
2026-03-23 16:18:51.087 [info] [Error - 4:18:51 PM] Client Microsoft.CodeAnalysis.LanguageServer: connection to server is erroring.
write EOF
Shutting down server.
2026-03-23 16:18:51.087 [info] [Error - 4:18:51 PM] Client Microsoft.CodeAnalysis.LanguageServer: connection to server is erroring.
write EOF
2026-03-23 16:18:51.088 [info] [Error - 4:18:51 PM] Request textDocument/diagnostic failed.
2026-03-23 16:18:51.088 [info]   Message: write EOF
  Code: -32099 
2026-03-23 16:18:51.088 [info] [Error - 4:18:51 PM] Document pull failed for text document file:///f%3A/sbox/shoothouse/Code/Game/Items/ItemInstance.cs
2026-03-23 16:18:51.088 [info]   Message: write EOF
  Code: -32099 
2026-03-23 16:18:51.088 [info] [Error - 4:18:51 PM] Client Microsoft.CodeAnalysis.LanguageServer: connection to server is erroring.
This socket has been ended by the other party
2026-03-23 16:18:51.089 [info] [Error - 4:18:51 PM] Request textDocument/diagnostic failed.
2026-03-23 16:18:51.089 [info]   Message: This socket has been ended by the other party
  Code: -32099 
2026-03-23 16:18:51.089 [info] [Error - 4:18:51 PM] Document pull failed for text document file:///f%3A/sbox/shoothouse/code/Weapons/Upgrades/WeaponUpgradeDefinition.cs
2026-03-23 16:18:51.089 [info]   Message: This socket has been ended by the other party
  Code: -32099 
2026-03-23 16:18:51.089 [info] [Error - 4:18:51 PM] Connection to server got closed. Server will not be restarted.
2026-03-23 16:18:51.090 [info] [Error - 4:18:51 PM] Stopping server failed
2026-03-23 16:18:51.090 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2026-03-23 16:18:51.091 [info] [Error - 4:18:51 PM] Stopping server failed
2026-03-23 16:18:51.091 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2026-03-23 16:18:51.091 [info] [Error - 4:18:51 PM] Stopping server failed
2026-03-23 16:18:51.091 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2026-03-23 16:18:51.100 [info] Language server process exited with 0

Steps to Reproduce

  1. Ask an gent to make some changes
  2. When it applies the changes the language server crashes

Expected Behavior

I shouldn’t have to reload the window every time the agent makes a change to my code just so I can have intellisense.

Operating System

Windows 10/11

Version Information

Version: 2.6.21 (user setup)
VSCode Version: 1.105.1
Commit: fea2f546c979a0a4ad1deab23552a43568807590
Date: 2026-03-21T22:09:10.098Z
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.22631

Does this stop you from using Cursor

Yes - Cursor is unusable

I pretty much cannot use Cursor because of this bug. It is recent and happened within the last 7 days.

Hey, thanks for the detailed report with logs, everything’s clear.

From the stack trace, it looks like when applying changes the Cursor agent sends a duplicate textDocument/didOpen for files that are already open, and that crashes Roslyn. That’s a bug on our side. I’ve shared it with the team, your report will help us prioritize it.

For now, here are a couple workarounds:

  1. After the server crash, try Restart Language Server from the Command Palette using Ctrl+Shift+P instead of doing a full reload window, it should be faster.
  2. Try closing all open .cs files before starting the agent, that might reduce the chance of a conflict since the files won’t be in an already open state.

Let me know if any of this helps even a bit.