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?
Asked
Active
Viewed 4,768 times
4 Answers
7
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.

Nikolaus
- 1,859
- 1
- 10
- 16
-
I've unloaded and reloaded all projects, but I still got this message. I can build solution, but Intelli sense is not working for imported namespaces. – FrenkyB May 20 '19 at 22:46
-
@FrenkyB Then try Marco Pavic‘s solution. – Nikolaus May 21 '19 at 04:24
-
This is still happening, and this solution didn't work for me. – VariableSquid Feb 27 '22 at 11:25
-
@VariableSquid Did you try any of the other solutions? – Nikolaus Mar 01 '22 at 10:06
-
@Nikolaus Yes, it was to do with making a x64 only solution. I now have a development build for editing the forms, and another one for a 64 bit only build. Not the best. I found the solution here: https://stackoverflow.com/questions/15835360/c-sharp-winforms-designer-wont-open-because-it-cannot-find-type-in-same-assembl – VariableSquid Mar 01 '22 at 15:03
6
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

Marko Pavic
- 81
- 2
- 5
-
I've also did this and it's not working. Which version of visual studio are you using? – FrenkyB May 21 '19 at 04:45
-
2
In my case I had csproj.user file that I've removed and then reloaded the project.

Anastasiya Mazheika
- 167
- 4
0
This issue occurred in VS 2019 while participating in a C# Essential Training course. My solution is:
- Save the entire project
- Close project
- Open project