我收到以下错误:
'MyNamespace.MyBaseClass' does not contain a definition for 'MyMethod' and no extension method 'MyMethod' accepting a first argument of type `MyMamespace.MyBaseClass' could be found (are you missing a using directive or an assembly reference?)
当我选择调用方行中的方法并执行 [Go to Definition] 时,Visual Studio 会在预期的位置找到方法声明。
当方法名称更改为MyMethod_ABC
并选择[Generate method stub] 时,方法MyMethod_ABC
会在MyMethod
旁边创建,方法相同签名,只有参数名称不同。
项目无法构建。有人能看出有问题吗?
最佳答案
对于像我一样正在寻找解决方案的任何人:
我刚遇到这个问题,但事实证明,在包含我尝试使用的方法的引用项目中存在一个小的编译错误,并且由于该项目从未使用新方法成功编译过,因此使用它在另一个项目中是无效的。修复了错误,我不再收到此错误。
关于c# - 错误 "Class does not contain a definition for method"但方法存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6821500/