VS Code does not find some classes. cs0246/cs0103

Hello everyone!
When I open Visual Studio Code, I get two error for some of my classes inherited from MonoBehaviour and ScriptableObject:
cs0246: The type or namespace name could not be found
For a static class:
cs0103:The name ____ does not exist in the current context.
If I open files with these classes and save them again (just “ctrl + s”, nothing more), then the problems disappear. I can build the project even without resolving the problems. But if I close VS Code and open it again, I get these errors again.
All files are placed in the same folders as the files that do not arise any errors.

How can I fix it?

OS: Windows 10, 64bit
Visual Studio Code version: 1.41.1
C# extension version: 1.21.10 (C# for Visual Studio Code (powered by OmniSharp))
Unity version: 2019.3.0f6

Try the following steps:-

  1. Open Unity
  2. Open Package Manager Window
  3. Check the version of your visual studio code package

If you are use package version 1.1.4 use the following steps to resolve the error:-

  1. In Unity, go to Window/Package Manager
  2. Search for your Visual Studio Code Editor package
  3. Downgrade to version 1.1.3
  4. Close Unity
  5. Delete your .csproj and .sln files in your project
  6. Open Unity
  7. Reopen VS Code and the errors are gone

Today November 24th, 2020
I had the same issue with Unity 2019.4.13 (LTS) and Visual Studio Code Package (v 1.2.2)
Instead of downgrading to 1.1.3, there was an update for v 1.2.3

I followed the steps of upgrading the package, closing unity, deleting the sln and csproj, then openeing Unity and vscode and it WORKED!

Thanks a lot

OS : Ubuntu:20.04

VSCode : 1.51.1

Unity : 2019.4.15f1

Visual Studio Code Package : v1.2.3

I had the same problem, I didn’t downgrade the vscode package. Simply

  1. Close Unity
  2. Delete .sln and .csproj and close vscode
  3. Restart unity and regenerate project file by EditPreferencesExternal ToolsRegenerate Project Files.

I’m on Unity 2019.4.11f1 and package 1.2.2 and randomly had issues today where only one csproj was working at a time, anything from other namespaces from other csproj files were not being recognised. I followed these steps, downgraded and deleted the .sln and now it’s working normally again. Thank you

I also go this in the past and I’m now on 2019.3.10f1 and still got it. However if you just run and stop your project in unity and make sure all errors are resolved, the missing class imports in vs code will be fixed.

Using Unity 2020.1.2f1 and VS Code 1.51 just follow those (@RahulRaman ) step, except downgrading change to upgrading to current version (1.2.3 on my case). It’s really work.

Great Thanks

I’ve imported the “Nethereum” Unity plugin, in Unity 2021.x, and none of these solutions is working…