vscode-csharp: Intellisense (omnisharp) crashes after typing.
I posted this in the Visual Studio Code issues and they told me to post it here saying that it’s the C# extension’s issue. I basically try to use Intellisense and it crashes. I can use it for 1 second and then it crashes every time, giving me this error: “Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.” This error happens in every project & every script. I have already done an uninstall and reinstall. I have also tried different versions of Visual Studio Code. I have also tried 3 different versions of the C# extension.
I have also used the most recent version, and neither work (currently reverted to 1.23 to see if that fixed it, but nope).
This is my entire error log:
Starting OmniSharp server at 1/21/2022, 4:57:14 PM Target: c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker\Legend Maker.sln
OmniSharp server started. Path: c:\Users\nicep.vscode\extensions\ms-dotnettools.csharp-1.23.17.omnisharp\1.38.1-beta.44\OmniSharp.exe PID: 9444
Starting OmniSharp on Windows 6.2.9200.0 (x64)
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
Using the 'dotnet' on the PATH.
DotNetPath set to dotnet
Located 1 MSBuild instance(s)
1: StandAlone 17.0.0 - "c:\Users\nicep\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.38.1-beta.44\.msbuild\Current\Bin"
MSBUILD_EXE_PATH environment variable set to 'c:\Users\nicep\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.38.1-beta.44\.msbuild\Current\Bin\MSBuild.exe'
Registered MSBuild instance: StandAlone 17.0.0 - "c:\Users\nicep\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.38.1-beta.44\.msbuild\Current\Bin"
CscToolExe = csc.exe
CscToolPath = c:\Users\nicep\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.38.1-beta.44\.msbuild\Current\Bin\Roslyn
MSBuildExtensionsPath = c:\Users\nicep\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.38.1-beta.44\.msbuild
MSBuildToolsPath = c:\Users\nicep\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.38.1-beta.44\.msbuild\Current\Bin
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
Detecting Cake files in 'c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker'.
Did not find any Cake files
Detecting projects in 'c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker\Legend Maker.sln'.
Queue project update for 'c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker\Assembly-CSharp.csproj'
Detecting CSX files in 'c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker'.
Did not find any CSX files
Configuration finished.
Omnisharp server running using Stdio at location 'c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker' on host 15756.
Loading project: c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker\Assembly-CSharp.csproj
Successfully loaded project file 'c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker\Assembly-CSharp.csproj'.
Adding project 'c:\Users\nicep\Documents\Game Projects\Legend-Maker\Legend Maker\Assembly-CSharp.csproj'
Update project: Assembly-CSharp
Received response for /quickinfo but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /v2/blockstructure but could not find request. Received response for /v2/getcodeactions but could not find request.
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at OmniSharp.Helpers.DiagnosticExtensions.<>c.<DistinctDiagnosticLocationsByProject>b__2_0(DocumentDiagnostics x) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Helpers\DiagnosticExtensions.cs:line 38
at System.Linq.Enumerable.<SelectManyIterator>d__233.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()
at System.Linq.Lookup2.Create[TSource](IEnumerable
1 source, Func2 keySelector, Func
2 elementSelector, IEqualityComparer1 comparer) at System.Linq.GroupedEnumerable
3.GetEnumerator()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator
1.MoveNext()
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
at OmniSharp.Protocol.Packet.ToString() in D:\a\1\s\src\OmniSharp.Host\Protocol\Packet.cs:line 22
at System.IO.TextWriter.WriteLine(Object value)
at System.IO.TextWriter.SyncTextWriter.WriteLine(Object value)
at OmniSharp.Services.SharedTextWriter.ProcessWriteQueue() in D:\a\1\s\src\OmniSharp.Host\Services\SharedTextWriter.cs:line 48
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 21 (2 by maintainers)
Same here. Yesterday was fine, but it omnisharp crashes today. Jan/22
@dreammixgames I see you have
omnisharp.path
set tolatest
in your configuration. If you remove that and restart, do you see the same issue?@DavidZidar It sounds entirely plausible that you might end up with
null
elements in aList<T>
if you’re trying to do concurrent adds to the list. It also seems plausible that this kind of behavior is something that might potentially differ between Mono and .NET 6, which would explain why switching to the latter seems to work around this issue (but may of course result in missing elements or other incorrect state rather thannull
elements).I managed to reproduce the issue and implemented a fix, works on my machine. OmniSharp/omnisharp-roslyn/pull/2333