Visual Studio 2013 reporting erroneous "does not contain a definition for" error for recent extension methods
Asked Answered
V

6

10

Visual Studio 2013 (vs) compiles a solution fine when manually building (i.e., it reports "Build succeeded", there are no errors in the error list, and running a program shows the latest changes). However, when vs starts building in the background (for Intellisense?), then errors start to come up for recently added extension methods. The extension methods are underlined in red, and right-clicking on them to "go to definition" results in an error that says "Cannot navigate to [method name]".

Extension methods that were created (in the same classes as the methods listed in the erroneous error messages) previous to when this started happening do not show up in the error messages.

I have done a build clean, to no avail.

I do not have resharper installed.

How do I reset the intelisense cache in Visual Studio 2013? I see instructions for Visual Studio 2008, but not for Visual Studio 2013.

Vidovic answered 31/7, 2014 at 13:59 Comment(7)
Have you closed the project and reopened or closed VS and reopened? I've noticed VS sometimes caches some things for background processing only and it sometimes needs to be restarted to clear it.Dorman
@Dorman Yes, I tried that and the errors came back after restarting.Vidovic
Try the steps here to reset your Intellisense: Visual Studio 2012 - Intellisense sometimes disappearing / broken - should work for VS 2013 as well.Tittup
@JasonZ Edit > IntelliSense does not have a "refresh local cache" submenu in Visual Studio 2013Vidovic
@Vidovic did you try the other steps? How about deleting your .suo file?Tittup
It doesn't solve your problem but it may help to know that VS provides IntelliSense but the compiler (csc.exe) does the actual compiling. (That will change somewhat in the future when the compiler provides parsing and binding information to any program that wants it.)Bessiebessy
The "using" clauses imports the right namespaces for the extension methods? Other idea is to kill .suo and .user files and restart visual studio. Maybe helps.Showboat
V
8

It turns out that closing all open files, then shutting down Visual Studio, and restarting fixed the issue. pff!

Vidovic answered 22/9, 2014 at 15:14 Comment(1)
Ha! Simple restart of VS did not work for me, but closing all the files first (and running a clean) worked! Thanks!Psychognosis
C
10

For Visual Studio 2015, my solution didn't have an .sdf file, and restarting didn't help. However, the following steps fixed my problem:

  1. Close Visual Studio (important)
  2. Go to [solution folder]\.vs\[solution name]\v14
  3. Delete the .suo file
  4. Start Visual Studio
Casi answered 27/4, 2016 at 3:45 Comment(0)
V
8

It turns out that closing all open files, then shutting down Visual Studio, and restarting fixed the issue. pff!

Vidovic answered 22/9, 2014 at 15:14 Comment(1)
Ha! Simple restart of VS did not work for me, but closing all the files first (and running a clean) worked! Thanks!Psychognosis
Z
3

I had a similar problem that I resolved by deleting *.sdf file in the solution directory. VS2013 will re-create it.

UPDATE This is what I know now: https://mcmap.net/q/1162194/-visual-studio-project-dependencies

Zipangu answered 15/8, 2014 at 14:26 Comment(1)
+1. This is the intellisense database file. If you're having problems with intellisense, this is the first thing to try.Acetate
S
0

After testing all above mentioned solutions simply clean and build worked for me.

Subscript answered 3/4, 2020 at 11:3 Comment(0)
H
0

In VS2010, the only thing that worked for me was removing and adding the reference again.

Highwrought answered 13/5, 2020 at 13:59 Comment(0)
J
0

Very old question, but it happened to me also with VS2019. I have multiple projects in my solution: right-click on the project -> "Unload Project" for each one, and then reload them. This worked for me.

  • Clean + Build, or
  • Close all the files + restart VS + clean

Those didn't work (for me).

Jerrilyn answered 2/11, 2021 at 8:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.