问题
-
当试着进入到运行模式时,接收到如下的错误信息:
error CS1061: Type `__' does not contain a definition for `__' and no
extension method `__' of type `__' could be found (are you missing
a using directive or an assembly reference?)
原因
当您尝试调用方法或访问不存在的类成员时,会导致CS1061错误。
下面的示例显示了通过Class1调用SayGoodbye方法。 我们可以看到Class1不包含Say Goodbye方法的定义。
此示例中显示的错误:
error CS1061: Type `Class1' does not contain a definition for
`SayGoodbye' and no extension method `SayGoodbye' of type
`Class1' could be found (are you missing a using directive
or an assembly reference?)
解决方案
要修复CS1061错误,您需要确保方法或类成员存在并通过正确的路径访问。
更多信息
https://msdn.microsoft.com/en-us/library/bb383961.aspx