1

I am getting these errors in Visual Studio:

Error CS0234 The type or namespace name 'X' does not exist in the namespace 'Y' (are you missing an assembly reference?)

But the namespace and type in fact exist and the code compiles just fine. So I assumed this was a cache related issue, the things I've tried:

  • Clean/Rebuild
  • Clear Temp folder

  • Remove ComponentModelCache as explained here

  • Clear ReSharper cache
  • Delete bin/obj folders

None of them seems to work. I'm using Visual Studio 2017 v15.8.0.

I don't know if it's related but this started happening after I created another branch, made a hard reset to a commit that was two years ago and then checkout to the current branch. Everything works fine, as I said project compiles but the errors are not going away from the IDE.

How can I get rid of them?

Selman Genç
  • 100,147
  • 13
  • 119
  • 184

2 Answers2

3

According to this earlier answer (pertaining to Visual Studio 2015), deleting .vs/{solution}/vs15/.suo should work.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Obsidian Age
  • 41,205
  • 10
  • 48
  • 71
1

What else you can try:

  • If the type is in a referenced project or assembly: Remove the reference and re add it.

  • Close VS and reopen it.

Usually Clean/Rebuild is sufficient. Clearing the component cache helps when components are broken.

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188