Share via


No overload for method takes 2 arguments_

Question

Friday, August 8, 2014 5:42 PM

this is my code i want my web application's form when i click a button it calls a method from my web service but i am getting this error " No overload for method 'HelloWorld' takes 2 arguments " what can i do 

        protected void Button1_Click(object sender, EventArgs e)
        {
          localhost.Service1 mys= new localhost.Service1();
          string nam = TextBox1.Text;
          string pas = TextBox2.Text;
          TextBox3.Text = mys.HelloWorld(nam, pas);
    
        }

All replies (2)

Friday, August 8, 2014 7:31 PM âś…Answered

The error message means that the HellpWorld method that you created does not take two parameters. It may have one, or three, and therefore it doesn't match the signature of your invocation.

Note that you are not calling the actual method in your webservice. You are calling the method in the proxy that was automatically generated when you added the web reference. This means that even if you modify the web service so that the method does take two parameters, you will still receive the error until you refresh the proxy so that it matches the real method in the service (in Visual Studio right-click on the web reference and select the option to update it).


Saturday, August 9, 2014 3:36 AM

You must declare the method "HelloWorld" in your service1 like this

public string HelloWorld(string n, string p)

{

    string t = n + " " + p;

    return t;

}

or similar, it will works.