Answer a question

I use VSCode for Unity development. Unfortunately, I'm not getting any IntelliSense within VSCode for my C# code. The root cause appears to be OmniSharp failing to find Mono, as the OmniSharp Logs within VSCode read: "[ERROR] Error: Cannot start OmniSharp because Mono version >=6.4.0 is required."

This is an issue I've run into multiple times. On 3/4/2021 and for months prior everything was working just fine and IntelliSense was working perfectly for multiple Unity projects and multiple Unity versions. Then the next day it broke for some unknown reason and didn't work for any project, until late at night after trying a bunch of things I was able to get it working. And now this morning I'm once again getting this error. Each time between it working and it breaking I didn't make any changes besides restarting my computer.

  • MacOS Mojave 10.14.6
  • Unity 2020.2.0f1 + Visual Studio Code Editor 1.2.3 package for Unity
  • VSCode 1.54.1 + C# 1.23.0 plugin for VSCode
  • Mono 6.12.0.122 installed at /usr/local/bin/mono via brew
  • Mono 6.12.0 also installed manually at /Library/Frameworks/Mono.framework/Versions/Current/Commands/
  • which mono in my terminal and VSCode's terminal outputs /usr/local/bin/mono
  • mono --version in both terminals outputs Mono JIT compiler version 6.12.0.122
  • echo $PATH contains paths to both versions of Mono, /usr/local/bin/mono appearing first
  • msbuild outputs Microsoft (R) Build Engine version 16.6.0 for Mono and which msbuild outputs /usr/local/bin/msbuild
  • dotnet --info outputs .NET Core SDK Version: 3.1.201

In my VSCode's settings I've set the following:

"omnisharp.loggingLevel": "debug",
"omnisharp.monoPath": "/usr/local/bin/mono",
"omnisharp.useGlobalMono": "always"

Things I've tried:

  • Downgrading/upgrading VSCode's C# plugin (including to the latest version of 1.23.9)
  • Downgrading Unity's Visual Studio Code Editor package
  • Switching VSCode to use the version of Mono 6.12.0 I manually installed at /Library/Frameworks/Mono.framework/Versions/Current/Commands/ (and uninstalling the brew-installed version)
  • Unsetting the omnisharp settings in VSCode (it leads to a different error about .NET SDKs)
  • Deleting Unity's .csproj and .sln files so that it can regenerate them
  • Manually telling Unity to regenerate all the .csproj files
  • Restarting
  • Looking at many forums posts and Stack Overflow questions on the topic for solutions

So does anyone have any suggestions for getting IntelliSense working in VSCode? Any tips for debugging why OmniSharp can't find Mono? I feel like I've done everything in my power to point OmniSharp to the correct place, I wish it logged a bit more about what it was trying.

Answers

I was able to resolve the issue by downgrading Visual Studio Code to 1.52.1 at https://code.visualstudio.com/updates/v1_52 and turning off automatic updates in VS Code. OmniSharp is now working without any exceptions. Seems likely that the root cause lies with VS Code 1.54 (or possibly 1.53)

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐