'OmniSharp fails to load properly in Visual Studio Code

I've recently started to write in C# on VSC using the 'C#' extension by Microsoft and I've been noticing that intellisense doesn't work at all. Every time I open a file, OmniSharp provides a log of its activity and I've noticed that it's been erroring every time.

I think the point of interest is the very last line where it states [ERROR]; however, I've provided the whole log in case it provides any more context. Here's that log:

Starting OmniSharp server at 4/14/2022, 6:42:08 PM
    Target: c:\Users\emowe\LearningUnity2D

OmniSharp server started.
    Path: c:\Users\emowe\.vscode\extensions\ms-dotnettools.csharp-1.24.4-win32-x64\.omnisharp\1.38.2\OmniSharp.exe
    PID: 25400

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
        Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
System.IO.FileNotFoundException: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Microsoft.Build.dll
   at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
   at OmniSharp.MSBuild.Discovery.MSBuildInstanceProvider.GetMSBuildVersion(String microsoftBuildPath) in D:\a\1\s\src\OmniSharp.Host\MSBuild\Discovery\MSBuildInstanceProvider.cs:line 103
   at OmniSharp.MSBuild.Discovery.Providers.MicrosoftBuildLocatorInstanceProvider.<>c.<GetInstances>b__1_0(VisualStudioInstance instance) in D:\a\1\s\src\OmniSharp.Host\MSBuild\Discovery\Providers\MicrosoftBuildLocatorInstanceProvider.cs:line 46
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at OmniSharp.MSBuild.Discovery.MSBuildLocator.GetInstances() in D:\a\1\s\src\OmniSharp.Host\MSBuild\Discovery\MSBuildLocator.cs:line 134
   at OmniSharp.MSBuild.Discovery.Extensions.GetBestInstance(IMSBuildLocator msbuildLocator, Version minimumMSBuildVersion, ILogger logger, Boolean& invalidVSFound, Boolean& vsWithoutSdkResolver) in D:\a\1\s\src\OmniSharp.Host\MSBuild\Discovery\Extensions.cs:line 109
   at OmniSharp.MSBuild.Discovery.Extensions.RegisterDefaultInstance(IMSBuildLocator msbuildLocator, ILogger logger, DotNetInfo dotNetInfo) in D:\a\1\s\src\OmniSharp.Host\MSBuild\Discovery\Extensions.cs:line 17
   at OmniSharp.CompositionHostBuilder.Build(String workingDirectory) in D:\a\1\s\src\OmniSharp.Host\CompositionHostBuilder.cs:line 71
   at OmniSharp.Stdio.Host..ctor(TextReader input, ISharedTextWriter writer, IOmniSharpEnvironment environment, IServiceProvider serviceProvider, CompositionHostBuilder compositionHostBuilder, ILoggerFactory loggerFactory, CancellationTokenSource cancellationTokenSource) in D:\a\1\s\src\OmniSharp.Stdio\Host.cs:line 49
   at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in D:\a\1\s\src\OmniSharp.Stdio.Driver\Program.cs:line 74
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass146_0.<OnExecute>b__0(CancellationToken _)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<ExecuteAsync>d__157.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at OmniSharp.HostHelpers.Start(Func`1 action) in D:\a\1\s\src\OmniSharp.Host\HostHelpers.cs:line 30
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

I've looked at other forum posts that share a similar problem and the common theme is that changing 'omnisharp.projectLoadTimeout' will fix the problem, but it hasn't for me. I've changed the value to 600 (10 minutes) and it still times out.

What's going on here? Why is OmniSharp always timing out? How do I fix this? Any help is appreciated and I'm happy to provide more context if needed.



Solution 1:[1]

It turns out that when initially installing Visual Studio something had gone wrong and a file that should have been installed didn't install. Doing a fresh reinstall of Visual Studio fixed the problem and intellisense now works properly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheTypicalDoge