Victor Chelaru
Victor Chelaru

Reputation: 4847

Why does Visual Studio incorrectly show errors in intellisense, but not build?

I have a class named Strings which has some const strings. I am referencing these consts from another class named TestScript1.

Both Strings and TestScript1 are in the same project.

Intellisense is reporting an error when I access the consts from Strings in TestScript1 as shown in the following image:

enter image description here

However, if I compile and run the project, everything works fine - no compile errors, no runtime exceptions. Furthermore, if I change the error window to show "Build Only" errors, no errors appear on build, but I still see the squiggly red underlines.

Things I've tried:

Is there anything I can do to get Visual Studio's intellisense to realize that this is not in fact a compile error?

Update 1: Here's some more details and things I've tried.

The Storyvania.DataTypes namespace contains 5 other classes. Those all show up just fine in intellisense, it's just the Strings class.

I am using Visual Studio Community 2017, Version 15.4.1.

The problem I'm experiencing is not only a syntax error but the dropdown that appears when typing does not recognize the Strings class.

I've also tried (to no avail):

Upvotes: 2

Views: 2235

Answers (1)

zendu
zendu

Reputation: 1235

VS 2019 also has the problem. It seems that VS fails to clear/update some of the data they cache. Try deleting folders named .vs from root of your repository/solution and its subfolders.

Upvotes: 5

Related Questions