- Home /
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
Hey I have this issue, but the errors appear in the console. Any idea how to fix it? I'm trying to reference a ScriptableObject in another Package using package dependencies, but the type is not found.
Answer by RahulRaman · Feb 06, 2020 at 02:51 PM
Try the following steps:-
Open Unity
Open Package Manager Window
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:-
In Unity, go to Window/Package Manager
Search for your Visual Studio Code Editor package
Downgrade to version 1.1.3
Close Unity
Delete your .csproj and .sln files in your project
Open Unity
Reopen VS Code and the errors are gone
Thanks ! The version 2.0.0 is available on beta and works as well
This worked like a charm! Only thing I did differently was that instead of downgrading to 1.1.3
, I upgraded to 1.2.3
, which was released earlier this month... and it works. Thanks again!
Answer by stack86 · Oct 14, 2020 at 03:33 AM
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
Answer by MohammedOmarPF · Nov 24, 2020 at 10:05 PM
Awesome! 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
Answer by ironWolf1990 · Nov 30, 2020 at 03:00 AM
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
Close Unity
Delete .sln and .csproj and close vscode
Restart unity and regenerate project file by
Edit
->Preferences
->External Tools
->Regenerate Project Files.
Answer by Beastman632 · Apr 23, 2020 at 06:24 PM
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.
Your answer
Follow this Question
Related Questions
hack and slash game errors 3 Answers
Visual studio 2019 0 Answers
Getting IP Address of clients (LL API) 1 Answer
cannot add sliders or progressbar 1 Answer
Error cs0433 - Accord.net 0 Answers