Cannot start OmniSharp because Mono version >=6.4.0 is required - c#

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.

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)

I had this same problem (no Intellisense). Tried many of the things listed here and elsewhere. Turned "ominsharp.useGlobalMono" to "never" as suggested most places, and restarted omnisharp when prompted, and it changed nothing. However, I got an error that I didn't get before (didn't save it, but it's the message stating that older versions of mono(?) aren't supported).
I therefore put it back (to "always") and restarted omnisharp when prompted...and autocomplete works. Didn't even exit VS code. Scripts were still open. No clue why it works now, but it does. So....set to never and back to always?
Using VS Code v 1.55.2.
Using dotnet 5.0.202

Set "omnisharp.useGlobalMono" to "never", and make sure you have a .NET .sln file for your project in the root of your workspace. If the solution is not in the root of your workspace, press Ctrl+Shift+P, and run "OmniSharp: Select Project" to select your .sln file.

Related

Omnisharp mono fails to load because of "No export was found for the contract 'ILoggerFactory'

This issue popped up just today as it was working fine just a day ago.
I tried reinstalling mono, visual studio code, rebooting my computer, but nothing worked. This is on the m1 macbook if that makes any difference, but I doubt it has anything to do with the ARM chip...
Here's a temporary fix.
However, all this does is change the version of omnisharp to the lower, default version pinned to the C# extension. It's still unclear why the newer versions are failing.

Why is VS Code not showing errors in C# (Unity)

I'm using VS Code and Unity, and I noticed that errors are showing on Unity console but not the VS Code, I looked up and did everything that this page says and nothing worked: https://code.visualstudio.com/docs/other/unity
Is there a fix to this?
I had this problem too. One day Code's errors were connected, the next day, they had disappeared. Most frustrating. This worked for me:-
Install the latest .net SDK from here DotNet SDK download
2) Regenerate project files from Edit->Preferences->External Tools
Note: just regenerating the project files didn't work for me. Needed DotNet SDK update.

Visual Studio Code : The 'C#' extension is recommended for this file type

So I recently installed visual studio code and added the C# available extensions. I also installed the Unity Debugger but it won't work because "it depends on an unknown 'ms-vscode.csharp' extension", I tried searching for this 'ms-vscode.csharp'in the extensions bar but found nothing. whenever i open a C# file from Unity or from any folder it recommends me to install that uknown C# extensions. what can i do please? here is a picture of the message:
To manually install the correct c# extension, do the following:
Uninstall existing vscode C# plugin
Close vscode
Download the vsix 1.21.12 from here
Open a command line in the folder where the vsix is.
Type: code --install-extension .\csharp-1.21.12.vsix
You should see:
Installing extensions...
Extension 'csharp-1.21.12.vsix' was successfully installed.
Open VSCode and in the C# output window, you will see:
Installing C# dependencies...
Platform: win32, x86_64
Downloading package 'OmniSharp for Windows (.NET 4.6 / x64)' (32544 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for Windows (.NET 4.6 / x64)'
Errors should now have gone away.
That was a mistake by Microsoft. I just spent hours to solve the problem and noticed that actually the name of the plugin was recently changed, leading to the error. We can fix it by manually downloading a previous version of the plugin.
Link:https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp&ssr=false#review-details
I don't do Unity development, but this may help: https://code.visualstudio.com/docs/other/unity
Keep in mind that VSCode is only going to be an editor for your project files.
(Can't comment, apologies for the brief answer)
I delete [.vscode\extensions], swith to 1.21.1/February 2018 and then update to 1.42.1. It finally works fine!
Maybe System setup doesn't have the problem. It only occurs on User setup.
That error happens because microsoft changed marketplace publisher from ms-vscode to ms-dotnettools. Mentioned here on github. You can just install the version v1.21.18 and that should solve it.

System namespaces missing MonoDevelop on fresh install

I am wondering if anyone can help me, I did a fresh install of MonoDevelop on a fresh install of Ubuntu 18.04.2 LTS with .NET Core 2.2 installed (everything updated), then followed the instructions layed out at Mono Download Offical. I have no errors or warnings during installation.
When I create any type of project or open one, all the system namespaces are missing?
I have checked here:
And
When I build / Clean any project I get:
/home/ant/.cache/MonoDevelop/7.0/MSBuild/27259_1/Microsoft.CSharp.CurrentVersion.targets(5,5):
Error MSB4019: The imported project
"/home/ant/.cache/MonoDevelop/7.0/MSBuild/27259_1//Microsoft.CSharp.Core.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk. (MSB4019) (sadsad)
Error
I solved it temporarily:
I went to the Namespace/Class options and under Run - Default - Advanced I selected Execute in .NET runtime -> Mono 5.20.1.34
It fixes the problem until i restart Monodevelop.
I'm having this problem since this morning, even after a fresh reinstall.
I am using Ubuntu MATE 18.04
This was a problem with mono its self, mono updated and was using a different version of MsBuild which the IDE could not use/understand. So I pulled the preview repository, as they added a fix there.
To fix:
purge monodevelop and mono-devel (with others) and install from here Preview - Stable until they patch the normal repository
I had the same problem with Monodevelop under Raspian (Rasberry3)
I believe I can now offer a viable solution:
It's just a setting that has to be done in Monodevelop before you start a new project:
Search under the settings, create and disable the line "create with MSBuild instead of xbuild".
After that all new projects will be recognized without errors.
For old projects the procedure is similar:
but there you should delete the folder ".vs" in the project folder first (better make a backup copy first! ;) ).
Start Monodevelop. Check that the settings are as described above.
Then open the project in Monodelop.
When you open the project, it will be reinitialized and can then be edited and compiled without any problems.

Visual Studio Code C# IntelliSense doesn't work after upgrade to v1.1.1

I'm using Visual Studio Code, as a code editor for Unity 5.
Visual Studio Code updated itself, after that I found that my C# IntelliSense seems to be broken. It doesn't show suggestions for my classes, it shows only c# syntax suggestions. I've checked all the settings, and logs so everything seems to be correct. There is right workspace settings, OmniSharp is running an no errors in Log. I've tried uninstall/install VSCode but no luck. I can't understand what is the problem, and I need your help.
Any solutions? Screenshots are below.
It may have to do with the C# Omnisharp plugin.
Support for .csproj projects has been temporarily disabled on OS X and Linux. This will impact anyone doing .csproj development on OS X or Linux (e.g. Unity, Xamarin, etc.). Rest assured that this will be restored in the near future. However, for now, you can use the Legacy C# Support extension.
https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

Categories