错误130 - 以下方法或属性之间的调用不明确

时间:2013-01-29 09:27:41

标签: c# user-controls

public static class MyExtensions
{
    public static bool TextBoxIsEmpty(TextBox txtControl, ErrorProvider eP)
    {
        if (txtControl.Text == string.Empty)
        {
            eP.SetError(txtControl, "You must Enter something!");
            return true;
        }
        else
        {
            eP.Clear();
            return false;
        }
    }
}

我在整个项目中使用此函数来验证空文本框。它正常工作,直到我将一个用户控件添加到我的一个WinForms。特别是,当Grid的数据源发生更改时,该User控件的实例会添加到我的表单中,但是我收到此错误。


  

错误129以下方法或属性之间的调用不明确:'DominateVehicle.Class.MyExtensions.TextBoxIsEmpty(System.Windows.Forms.TextBox,System.Windows.Forms.ErrorProvider)'和'DominateVehicle.Class.MyExtensions。 TextBoxIsEmpty(System.Windows.Forms.TextBox,System.Windows.Forms.ErrorProvider)'D:\ Vechel_Dominate \ a \ DominateVehicle \ frmDefectClass.cs 30 41 DominateVehicle


我不知道添加用户控件和此错误之间有什么关系? 如果我删除UserControl,我的代码不起作用,我收到一个错误。我该怎么办?

2 个答案:

答案 0 :(得分:4)

我也有这个错误。

总是当我在我的项目中添加一个控件到我的一个表单时,由于对所有扩展方法的调用模糊,我无法再编译。

最后我看到VS在同一个项目中添加了我的项目引用,因此编译器遇到了问题。然后它没有帮助删除您的代码,因为引用仍然存在。

我可以通过从项目中删除此引用来解决问题。也许这有助于其他任何人。

答案 1 :(得分:0)

此功能在两个地方定义。检查一下。编译器不知道要调用哪一个。找到您的解决方案。这个名称将有两个功能。

相关问题