Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'the type or namespace could not be found' in Visual Studio 2017

Every time I do a git pull from remote to update my branch, Visual Studio 2017 shows "the type or namespace could not be found" error in many files as I open them. Interestingly I don't see the problem in Visual Studio 2015 for the same projects/repo. The software builds fine in both versions of Visual Studio so it is a false error. Doing a Clean or Rebuild doesn't fix the problem. I end up re-cloning the repo from remote and then Visual Studio 2017 is happy. Any one knows how to fix this annoying problem?

like image 886
Ppp Avatar asked Oct 18 '17 20:10

Ppp


People also ask

How do I add a namespace in Visual Studio?

To add an imported namespaceIn Solution Explorer, double-click the My Project node for the project. In the Project Designer, click the References tab. In the Imported Namespaces list, select the check box for the namespace that you wish to add. In order to be imported, the namespace must be in a referenced component.

Is the type or namespace could not be found?

A type or namespace that is used in the program was not found. You might have forgotten to reference (References) the assembly that contains the type, or you might not have added the required using directive. Or, there might be an issue with the assembly you are trying to reference.

How do you solve cs0246?

If you hover your mouse over the red line under GridLayoutGroup (provided you use visual studio as your IDE) then a light bulb should appear. Hover your mouse over the light bulb, you will have an option like "Using UnityEngine. UI" click on it and your problem will be solved.


2 Answers

The problem is the package-restore. If it fails, you get the issue. You can try to unload and reload the projects, but I also still haven't found a way to avoid it.

like image 152
Nikolaus Avatar answered Sep 28 '22 01:09

Nikolaus


Unloading and reloading the project did not work work me.

Instead, I delete the hidden .suo file inside the project directory and everything started working again. The path is:

(project name) \ .vs \ (project name) \ v15 \ .suo

like image 31
Marko Pavic Avatar answered Sep 28 '22 01:09

Marko Pavic