Omnisharp does not work with Blazor server for me. It's been an ongoing issue for months and I have tried just about everything under the sun to fix it. I suspect there might be race conditions happening, as a lot of the time it fails it gives a system argument exception saying it can't find the .razor__virtual.cs file. But I really don't know. I have tried so many things to fix this issue but it just won't work. Intellisense just doesn't work in .razor files, but does in all my .cs files.
This is a very common message I get in the logs: Received response for /v2/getcodeactions but could not find request. The thing that gets me too is half the time it shows a fail in the output window, and half the time it just displays the above. I'll post two logs below: the first when an error occurs, the second where it thinks it's working but generates the could not find request message.
tl;dr is total failure of omnisharp in .razor files for months now.
Edit: I swear I've had error messages say that there is an argument exception because the file .razor__virtual.cs does not exist but I can't get it to reproduce that message. If it does, I will add it as a comment below, but it still gives an argument out of range exception which is posted in the logs below, with a request using the .razor__virtual.cs file. But I swear it sometimes says it can't find that file, which is different than the error message produced below.
Steps to Reproduce
dotnet new blazorserver
Navigate to a .razor file, such as Pages/Counter.razor.
Go into the @code section and type bool hello = "I do not work"; and you will see intellisense is perfectly happy to accept this. Again, sometimes I get things that give a failure message, sometimes I just get "could not find request" message, and sometimes nothing at all appears in the log and I assume omnisharp thinks it is working.
Expected Behavior
Intellisense to work in .razor files.
Actual Behavior
Intellisense does not work in .razor files and output log is inconsistent.
Logs
OmniSharp log on error
Starting OmniSharp server at 2022-10-20, 10:11:31 a.m.
Target: /home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules.sln
OmniSharp server started with .NET 6.0.402
.
Path: /home/parkhill/.vscode/extensions/ms-dotnettools.csharp-1.25.0-linux-x64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
PID: 121147
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to /usr/share/dotnet/dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.402 17.3.2 - "/usr/share/dotnet/sdk/6.0.402/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.402 17.3.2 - "/usr/share/dotnet/sdk/6.0.402/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/WebModules.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/parkhill/Documents/CultureFoundry/Coding/WebModules'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/parkhill/Documents/CultureFoundry/Coding/WebModules' on host 119013.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/WebModules.csproj
[info]: OmniSharp.OmniSharpWorkspace
Miscellaneous file: /home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/Pages/Teacher/Details.razor__virtual.cs added to workspace
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/WebModules.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/WebModules.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: WebModules
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
Solution initialized -> queue all documents for code analysis. Initial document count: 629.
[warn]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 127,
"Command": "/v2/getcodeactions",
"Arguments": {
"FileName": "/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/Pages/Teacher/Details.razor__virtual.cs",
"Line": 460,
"Column": 17
}
}
[fail]: OmniSharp.Stdio.Host
************ Response (26.0545ms) ************
{
"Request_seq": 127,
"Command": "/v2/getcodeactions",
"Running": true,
"Success": false,
"Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')\\n at Microsoft.CodeAnalysis.Text.SourceText.LineInfo.get_Item(Int32 index)\\n at OmniSharp.Extensions.TextExtensions.GetPositionFromLineAndOffset(SourceText text, Int32 lineNumber, Int32 offset) in /Users/runner/work/1/s/src/OmniSharp.Roslyn/Extensions/TextExtensions.cs:line 28\\n at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetTextSpan(ICodeActionRequest request, SourceText sourceText) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 116\\n at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 83\\n at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34\\n at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 201\\n at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 230\\n at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 131\\n at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /Users/runner/work/1/s/src/OmniSharp.Stdio/Host.cs:line 218\"",
"Body": null,
"Seq": 1012,
"Type": "response"
}
OmniSharp log without error but with codeactions message
Starting OmniSharp server at 2022-10-20, 10:13:56 a.m.
Target: /home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules.sln
OmniSharp server started with .NET 6.0.402
.
Path: /home/parkhill/.vscode/extensions/ms-dotnettools.csharp-1.25.0-linux-x64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
PID: 122087
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to /usr/share/dotnet/dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.402 17.3.2 - "/usr/share/dotnet/sdk/6.0.402/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.402 17.3.2 - "/usr/share/dotnet/sdk/6.0.402/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/WebModules.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/parkhill/Documents/CultureFoundry/Coding/WebModules'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/parkhill/Documents/CultureFoundry/Coding/WebModules' on host 121792.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/WebModules.csproj
[info]: OmniSharp.OmniSharpWorkspace
Miscellaneous file: /home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/Pages/Teacher/Details.razor__virtual.cs added to workspace
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/WebModules.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/home/parkhill/Documents/CultureFoundry/Coding/WebModules/WebModules/WebModules.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: WebModules
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
Solution initialized -> queue all documents for code analysis. Initial document count: 455.
Received response for /v2/getcodeactions but could not find request.
OmniSharp log where it thinks everything is okay
Starting OmniSharp server at 2022-10-20, 10:21:25 a.m.
Target: /home/parkhill/blazor
OmniSharp server started with .NET 6.0.402
.
Path: /home/parkhill/.vscode/extensions/ms-dotnettools.csharp-1.25.0-linux-x64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
PID: 125443
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to /usr/share/dotnet/dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.402 17.3.2 - "/usr/share/dotnet/sdk/6.0.402/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.402 17.3.2 - "/usr/share/dotnet/sdk/6.0.402/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
No solution files found in '/home/parkhill/blazor'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/parkhill/blazor/blazor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/parkhill/blazor'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/parkhill/blazor' on host 125226.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/parkhill/blazor/blazor.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/parkhill/blazor/blazor.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/home/parkhill/blazor/blazor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: blazor
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
Solution initialized -> queue all documents for code analysis. Initial document count: 17.
Razor log
--------------------------------------------------------------------------------
Razor.VSCode version 6.0.0-preview.5.21358.6
--------------------------------------------------------------------------------
Razor's trace level is currently set to 'Off'
- To change Razor's trace level set 'razor.trace' to 'Off', 'Messages' or 'Verbose' and then restart VSCode.
- To report issues invoke the 'Report a Razor issue' command via the command palette.
-----------------------------------------------------------------------------------------------------------------------------
[Client - 10:19:20 a.m.] (Warning) razor/provideCodeActions failed with Canceled: Canceled
Environment information
VSCode version: 1.72.2
C# Extension: 1.25.0
Mono Information
OmniSharp using mono :6.12.0Dotnet Information
.NET SDK (reflecting any global.json):
Version: 6.0.402
Commit: 6862418796
Runtime Environment:
OS Name: manjaro
OS Version:
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/6.0.402/
global.json file:
Not found
Host:
Version: 6.0.10
Architecture: x64
Commit: 5a400c212a
.NET SDKs installed:
6.0.402 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Download .NET:
https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs:
https://aka.ms/dotnet/runtimes-sdk-info
Visual Studio Code Extensions
|Extension|Author|Version|
|---|---|---|
|better-cpp-syntax|jeff-hykin|1.16.1|
|cpptools|ms-vscode|1.12.4|
|cpptools-extension-pack|ms-vscode|1.3.0|
|cpptools-themes|ms-vscode|1.0.0|
|csharp|ms-dotnettools|1.25.0|
|data-workspace-vscode|ms-mssql|0.3.0|
|foma-highlighting|scott-parkhill|1.0.0|
|highlight-matching-tag|vincaslt|0.10.1|
|jupyter|ms-toolsai|2022.9.1202862440|
|jupyter-keymap|ms-toolsai|1.0.0|
|jupyter-renderers|ms-toolsai|1.0.10|
|live-sass|glenn2223|5.5.1|
|makefile-tools|ms-vscode|0.6.0|
|markdown-all-in-one|yzhang|3.4.3|
|mssql|ms-mssql|1.16.0|
|pdfpreview|corentinartaud|1.0.0|
|python|ms-python|2022.16.1|
|sql-bindings-vscode|ms-mssql|0.3.0|
|sql-database-projects-vscode|ms-mssql|0.19.0|
|todo-tree|Gruntfuggly|0.0.219|
|user-secrets|adrianwilczynski|2.0.1|
|vim|vscodevim|1.24.1|
|vscode-dotnet-runtime|ms-dotnettools|1.5.0|
|vscode-jupyter-cell-tags|ms-toolsai|0.1.6|
|vscode-jupyter-slideshow|ms-toolsai|0.1.5|
|vscode-markdownlint|DavidAnson|0.48.1|
|vscode-pylance|ms-python|2022.10.30|
|vscode-thunder-client|rangav|1.20.1|;
Issue Description
Omnisharp does not work with Blazor server for me. It's been an ongoing issue for months and I have tried just about everything under the sun to fix it. I suspect there might be race conditions happening, as a lot of the time it fails it gives a system argument exception saying it can't find the
.razor__virtual.cs
file. But I really don't know. I have tried so many things to fix this issue but it just won't work. Intellisense just doesn't work in.razor
files, but does in all my.cs
files.This is a very common message I get in the logs:
Received response for /v2/getcodeactions but could not find request
. The thing that gets me too is half the time it shows afail
in the output window, and half the time it just displays the above. I'll post two logs below: the first when an error occurs, the second where it thinks it's working but generates the could not find request message.tl;dr is total failure of omnisharp in .razor files for months now.
Edit: I swear I've had error messages say that there is an argument exception because the file
.razor__virtual.cs
does not exist but I can't get it to reproduce that message. If it does, I will add it as a comment below, but it still gives an argument out of range exception which is posted in the logs below, with a request using the.razor__virtual.cs
file. But I swear it sometimes says it can't find that file, which is different than the error message produced below.Steps to Reproduce
dotnet new blazorserver
Navigate to a
.razor
file, such asPages/Counter.razor
.Go into the
@code
section and typebool hello = "I do not work";
and you will see intellisense is perfectly happy to accept this. Again, sometimes I get things that give a failure message, sometimes I just get "could not find request" message, and sometimes nothing at all appears in the log and I assume omnisharp thinks it is working.Expected Behavior
Intellisense to work in
.razor
files.Actual Behavior
Intellisense does not work in
.razor
files and output log is inconsistent.Logs
OmniSharp log on error
OmniSharp log without error but with codeactions message
OmniSharp log where it thinks everything is okay
Razor log
Environment information
VSCode version: 1.72.2 C# Extension: 1.25.0
Mono Information
OmniSharp using mono :6.12.0Dotnet Information
.NET SDK (reflecting any global.json): Version: 6.0.402 Commit: 6862418796 Runtime Environment: OS Name: manjaro OS Version: OS Platform: Linux RID: linux-x64 Base Path: /usr/share/dotnet/sdk/6.0.402/ global.json file: Not found Host: Version: 6.0.10 Architecture: x64 Commit: 5a400c212a .NET SDKs installed: 6.0.402 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Download .NET: https://aka.ms/dotnet-download Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-infoVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |better-cpp-syntax|jeff-hykin|1.16.1| |cpptools|ms-vscode|1.12.4| |cpptools-extension-pack|ms-vscode|1.3.0| |cpptools-themes|ms-vscode|1.0.0| |csharp|ms-dotnettools|1.25.0| |data-workspace-vscode|ms-mssql|0.3.0| |foma-highlighting|scott-parkhill|1.0.0| |highlight-matching-tag|vincaslt|0.10.1| |jupyter|ms-toolsai|2022.9.1202862440| |jupyter-keymap|ms-toolsai|1.0.0| |jupyter-renderers|ms-toolsai|1.0.10| |live-sass|glenn2223|5.5.1| |makefile-tools|ms-vscode|0.6.0| |markdown-all-in-one|yzhang|3.4.3| |mssql|ms-mssql|1.16.0| |pdfpreview|corentinartaud|1.0.0| |python|ms-python|2022.16.1| |sql-bindings-vscode|ms-mssql|0.3.0| |sql-database-projects-vscode|ms-mssql|0.19.0| |todo-tree|Gruntfuggly|0.0.219| |user-secrets|adrianwilczynski|2.0.1| |vim|vscodevim|1.24.1| |vscode-dotnet-runtime|ms-dotnettools|1.5.0| |vscode-jupyter-cell-tags|ms-toolsai|0.1.6| |vscode-jupyter-slideshow|ms-toolsai|0.1.5| |vscode-markdownlint|DavidAnson|0.48.1| |vscode-pylance|ms-python|2022.10.30| |vscode-thunder-client|rangav|1.20.1|;