none
No overload for method takes 2 arguments if winform in different application. No error if the same solution RRS feed

  • Question

  • Hi everybody,

    I created a simple WCF service and added winform client (name is WinAAA) to the SAME solution. It works fine.

    Now I want access WCF service from ANOTHER application.

    I created new application with winform (name is WinBBB), added reference to WCF service and COPIED code from WinAAA.

    It gives me error “No overload for method takes '2' arguments.

    It is the same WCF service. Winform clients WinAAA and WinBBB are identical.

    If WCF service and winform client in the same solution, it works.

    If winform is in another application, it gives an error.   

    What is wrong?

    Code for WCF Service:

     [ServiceContract]

        public interface IStatistic

        {

            [OperationContract]

            double CountMean(int Qty, double[] Arr);

        }

    public class Statistic : IStatistic

        {

            public double CountMean(int Qty, double[] Arr)

            {

                double result = Arr.Sum() / Qty;

                return result;

            }

        }

    Code for winform client in another application:

    public partial class FormBBB : Form

        {

            public List<double> Arr = new List<double>();

         private void btnAddNum_Click(object sender, EventArgs e)

         {

             string t = txtAddNum.Text.Trim();

             double d = Convert.ToDouble(t);

             Arr.Add(d);

         }

         private void btnCountMean_Click(object sender, EventArgs e)

         {

             int Qty = Arr.Count;

             double[] ArrayToService = Arr.ToArray();

            ReferenceStatisticWCF.Statistic RSt = new ReferenceStatisticWCF.Statistic();

            double result = RSt.CountMean(Qty, ArrayToService);

         }

    Error “No overload for method takes '2' arguments in a last line double result = RSt.CountMean(Qty, ArrayToService);

    What is wrong?

    Thank you.

    OkyToky


    Oak

    Saturday, May 16, 2015 10:11 PM

Answers

  • Hi OkyToky,

    First please try to update your WCF Service Reference, it seems that it should be something wrong with the services reference. Then please try to check the WinAAA config and the WinBBB config to see if there are any difference between them. Also please try to make sure that WCF Service is running during the consuming from the client side.

    >>If WCF service and winform client in the same solution, it works. If winform is in another application, it gives an error.

    I wonder if the WinBBB is in the different computer between the WinAAA and the WCF Services, if so please make sure that you are not using the localhost as address, you can try to enter the WCF Service address in the browser of the WinBBB computer to see if it works.

    >>It gives me error “No overload for method takes '2' arguments.”

    Besides, you can check which method is avaliable with the RSt by using the Visual Studio Intellisense.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, May 18, 2015 7:37 AM
    Moderator