Intellisense not working in VSCode - OmniSharp Error

Viewed 14248

Intellisense has stopped working for me and whenever I run VSCode this error comes up in the OmniSharp Log.

[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj'.
/Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj
/Users/leogaunt/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1178,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj

I have tried re-installing the plugin, and re-intsalling VSCode but it hasn't worked.

I know I have .NET Core installed as I am a Mac user and I know this because when I type dotnet --version in terminal it outputs:

3.1.401

I am programming in Unity and am creating a game for iOS.

8 Answers

Change the mono path to always, in C# extension config.

For anyone that uses VSCode v1.67.2 dotnet v3.x.x and OmniSharp v1.25.0 (or v1.23.17 and above).

The above accepted answer does not solve the issue.

The simplest thing to do is downgrade ms-dotnettools.csharp (C# Extension), the only issue is if you downgrade to any version above v1.23.16 it gives you "Can't install 'ms-dotnettools.csharp' extension because it is not compatible with the current version of Visual Studio Code (version 1.67.2)"

I suggest to downgrade it to version 1.23.16 and restart vscode.

Your Intellisense should start working.

My Environment
dotnet v3.1.417
VSCode v1.67.2
C# Extension v1.25.0 (now downgraded to v1.23.16)
Running in Remote Container on a Mac host.

Yes I am using 3+ year old dotnet version. It's a legacy software, it happens, everyone has skeletons in their systems ;)

Trust me it'll work, tried everything and then came to this

  1. Go into VS code Preferences
  2. Search for omnisharp.path and click on edit in settings.json
  3. Add/edit line "omnisharp.path": "latest" (remember to add a comma at the end of the previous line)
  4. Go back into settings and search omnisharp, scroll down till you find Use Global Mono, change that to Always
  5. After this you will have to download Mono, mac's mono download link is this https://www.mono-project.com/download/stable/#download-mac
  6. After the download finishes, set it up by opening the download file
  7. Go back to settings.json and add mono's /bin path as "omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/6.12.0/bin" which is the default download path for mac, if you wanna confirm this, go into mac's disk space and then follow the above mentioned path)
  8. Finally restart VS Code and it should work (in case it still doesn't, restart it again)

I downgraded the VS Code's C# extension to 1.24.3 from 1.25.0 and it worked.

I had the same Problem after fetching Unity from a git repository. For me it worked to reset the .Net Version in Unity. Edit -> Project Settings -> Api Compatibility Level

Switched that back and forth, restarted VSCode. The .csproj-file will file out all the missing dlls.

I solved this by uninstalling all SDK's and installed the older 4.7.1, then everything worked instantly.

I had the same problem. Here's how I fixed it:

I added all projects to the solution file (dotnet sln add <project name>) and opened the project in vs code by passing the path to vscode from terminal (code <project path>).

The error says that OmniSharp is looking for Version=v4.7.1. You may want to install the latest version of it.

Related