Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio saying name doesn't exist in current context

Tags:

I am calling a static method on a class like

Foo.bar() 

Visual studio's intellisense recognizes Foo and autocompletes bar for me (it highlights Foo and everything like it is working fine). Everything looks fine until I go to build the project, and it throws an error saying the name Foo doesn't exist in current context.

I am using this static method call in other files, so I know the class is ok. The situation is too big to post code, so I am mostly looking for reasons to start looking into that would cause intellisense to function normally but get errors on compile like this.

like image 902
Jarrod Everett Avatar asked Aug 21 '12 20:08

Jarrod Everett


People also ask

Does not exist in the current context means?

I know this error means that the control being referenced generally doesn't exist or is not a part of the class that's referencing it, but as far as I can see, that isn't the case here.

How to solve error CS0103?

CS0103 is caused when you are using a name for a variable or method that does not exist within the context that you are using it. In order to fix the CS0103 error you will need to correct the name of the variable or method from where it is declared or referenced.


1 Answers

I've seen this error caused by differing versions of the .NET framework in the different projects. The Class Library I built was 4.5 and the application was 4.0, but the only error it gave was namespace errors. Changing the framework version on the class library and rebuilding it, then the application, resolved the error.

like image 159
aherocalledFrog Avatar answered Nov 26 '22 16:11

aherocalledFrog