-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Description
Describe the Issue
Using C# and C# Dev Kit extensions, if I open a razor file, then delete it using solution explorer, I get a project load error.
Steps To Reproduce
Using the latest main builds of C# and C# Dev Kit with .NET 8 or .NET 9
- Open a folder with a razor/blazor solution
- Open a razor file in the editor
- Delete the currently open file using Solution Explorer
Actual:
2025-08-04 23:34:40.878 [info] [Error - 11:34:40 PM] [razor/documentClosed] [LSP] System.InvalidOperationException: Expected 'requestContext.DocumentUri' to be non-null.
File='/_/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Endpoints/RazorDocumentClosedEndpoint.cs', Line=33
at Microsoft.AspNetCore.Razor.ThrowHelper.ThrowInvalidOperationException(String message)
at Microsoft.AspNetCore.Razor.Assumed.ThrowInvalidOperation(String message, String path, Int32 line)
at Microsoft.AspNetCore.Razor.NullableExtensions.AssumeNotNull[T](T value, String message, String valueExpression, String path, Int32 line)
at Microsoft.VisualStudioCode.RazorExtension.Endpoints.RazorDocumentClosedEndpoint.HandleRequestAsync(TextDocumentIdentifier textDocument, RazorCohostRequestContext requestContext, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.AbstractRazorCohostRequestHandler`2.Microsoft.CommonLanguageServerProtocol.Framework.IRequestHandler<TRequestType,TResponseType,Microsoft.CodeAnalysis.LanguageServer.Handler.RequestContext>.HandleRequestAsync(TRequestType request, RequestContext context, CancellationToken cancellationToken) in /_/src/Tools/ExternalAccess/Razor/Features/Cohost/AbstractRazorRequestHandler.cs:line 21
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 191
2025-08-04 23:34:40.884 [error] Error making razor/documentClosed request Expected 'requestContext.DocumentUri' to be non-null.
Expected Behavior
The language server does not crash.
Environment Information
OS: Win x64 and MacOS x64/arm64
.NET 8 or .NET 9 latest public releases