How to solve Omnisharp .NetFramework error, affects intellisense...

Hey Unity Community and Team,
I can’t get those Omnisharp errors fixed…

Just noticed it because I changed my IDE from VS to Code,
First the intellisense didn’t work at all, got some of it fixed by installing mono to the system.

After restarting my system I started noticing intellisense stoped working and some errors in the console output log from OmniSharp.

Some references can not be resolved (47):

Error: The primary reference "CUSTOM" could not be resolved because it was built against the ".NETFramework,Version=v4.7.2" framework.
This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.1".

Does anybody have experienced this before, solved or just an idea what is going on, why this affects intillisense?
Would be nice to get rid of the errors and the intellisense running :slight_smile:

Unity Version // Installed Packages:
Unity 2021.3.3f1 LTS
.NET Framework 4.7.1 SDK
.NET Framework 4.7.1 Targeting Pack (ENU)
.NET Framework 4.7.2 SDK
.NET Framework 4.7.2 Targeting Pack
.NET Framework 4.7.2 Targeting Pack (ENU)
.NET Framework 4.8 SDK
.NET Framework 4.8 Targeting Pack
.NET Framework 4.8 Targeting Pack (ENU)
.NET SDK 5.0.400
.NET SDK 6.0.300
Mono 6.12.0 Stable (6.12.0.179)

1 Like

The information on how to configure OmniSharp-VSCode for Unity is a bit hard to find, unfortunately. I recommend checking out the Github repository and reading the changelog before every update.

In your case, I suspect your mono version is too old. If you check the Requirements section of the readme on Github, the mono link goes to the Preview version of mono. The stable version contains an older version of MSBuild that is not compatible with OmniSharp.

You’ll also need to change omnisharp.useModernNet to false in your VSCode configuration. When I changed it, I had to completely restart VScode for the change to apply properly, only restarting OmniSharp wasn’t enough.

1 Like