Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Class' does not contain a definition for 'Method'

In class Employee I've got some methods, which work fine. Now I wanted to add new method, for example

public void ExampleMethod()
{         
}

Then I call it

Employee employee = new Employee();
employee.ExampleMethod();

ExampleMethod is present in IntelliSense displayed after dot, when I hit F12 it also redirect me to that method, but while starting project I've got an error: 'Employee' does not contain a definition for 'ExampleMethod' and no extension method 'ExampleMethod' accepting a first argument of type 'Employee' could be found (are you missing a using directive or an assembly reference?)

I don't know why this error is caused, because all other earlier methods work fine. What's the problem?

like image 608
vanilla161 Avatar asked Sep 18 '12 10:09

vanilla161


People also ask

Does not contain definition for and no extension method?

'type' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'type' could be found (are you missing a using directive or an assembly reference?). This error occurs when you try to call a method or access a class member that does not exist.


1 Answers

There are three possibilities:

1) If you are referring old DLL then it cant be used. So you have refer new DLL

2) If you are using it in different namespace and trying to use the other namespace's dll then it wont refer this method.

3) You may need to rebuild the project

I think third option might be the cause for you. Please post more information in order to understand exact problem of yours.

like image 83
VIRA Avatar answered Oct 07 '22 17:10

VIRA