C# 错误“方法‘getData’没有重载需要‘1’个参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1453848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 17:42:15  来源:igfitidea点击:

C# Error 'No overload for method 'getData' takes '1' arguments

c#

提问by Rick

I am getting the following error:

我收到以下错误:

Error 49 No overload for method 'getData' takes '1' arguments 

With this method on the 5th line.

用这个方法在第 5 行。

    [WebMethod]
    public string getVerzekerde(int bsn)
    {
        ZDFKoppeling koppeling = new ZDFKoppeling();
        return koppeling.getData(bsn);             
    }

The getData method looks like this:

getData 方法如下所示:

    public string getData(int bsn)
    {         
        using (new SessionScope())
        {
            ZorgVerzekerde verzekerde = PolisModule.GetVerzekerde(bsn);
            return "Verzekerde " + verzekerde.Naam;          
        }     
    }

I realy don't understand what is going wrong here.. The description of this error on the msdn site didn't help me.. http://msdn.microsoft.com/en-us/library/d9s6x486%28VS.80%29.aspx

我真的不明白这里出了什么问题.. msdn 站点上对这个错误的描述对我没有帮助.. http://msdn.microsoft.com/en-us/library/d9s6x486%28VS.80 %29.aspx

Someone who has a solution?

有人有解决方案吗?

采纳答案by Noon Silk

Yeah; somehow you're compiling against a different version of that class. Do a clean build, and double check your references.

是的; 不知何故,您正在针对该类的不同版本进行编译。做一个干净的构建,并仔细检查你的参考。

回答by Nader Shirazie

Where is the getDatamethod defined? Is it in another assembly? Have you tried rebuilding?

getData方法在哪里定义?它在另一个程序集中吗?你试过重建吗?

It doesn't look like anything's wrong with your the code.

看起来您的代码没有任何问题。

回答by Ian Ringrose

Put an error in the GetData() method, then do a full build and confirm that the compiler find the errors. You may be editing the wrong file if you have more then one copy of the source code on your machine, and this will show you if you are.

在 GetData() 方法中放置一个错误,然后进行完整构建并确认编译器找到了错误。如果您的机器上有多个源代码副本,您可能正在编辑错误的文件,这将显示您是否是。

Also try renaming the ZDFKoppeling class without updating getVerzekerde() and check you get a compiler error. If not you are not picking up the changed class for some reason.

还可以尝试在不更新 getVerzekerde() 的情况下重命名 ZDFKoppeling 类并检查是否出现编译器错误。如果不是,您出于某种原因没有选择更改后的课程。

If the above does not give a compiler error, try a rebook, as a process my have the dll locked, and also try a complete rebuild.

如果以上没有给出编译器错误,请尝试重新预订,因为我锁定了dll,并尝试完全重建。

These problems normally turn out to be very simple once you have tracked them down. But get take forever to track down.

一旦您追踪到这些问题,通常会变得非常简单。但是得到永远追踪。

If another programmer works in the same office, ask for his/her help, as often a 2nd set of eye on the machine can find it quickly.

如果另一个程序员在同一个办公室工作,请寻求他/她的帮助,因为机器上的第二眼通常可以很快找到它。

(I am assuming that GetData() is defined in the ZDFKoppeling class, not some other calss)

(我假设 GetData() 是在 ZDFKoppeling 类中定义的,而不是其他一些类)

回答by ICR

This generally indicates that it's not referencing the method you thought it was, but instead a different one. You can generally find out what method that is in Visual Studio by right clicking the method call and selecting "Go to definition". This should help work out why it's calling the one it is and not the one you expect.

这通常表明它没有引用您认为的方法,而是引用了不同的方法。您通常可以通过右键单击方法调用并选择“转到定义”来找出 Visual Studio 中的方法。这应该有助于弄清楚为什么它会调用它,而不是你期望的那个。