Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

no overload for method takes 0 arguments, in a method which does not need an argument

(1) ShareShare
ReportReport
Posted on by 148

Hi,

I developed a simple service in AX2012 which only has a method for counting everytime the service gets consumed.

 

[SysEntryPointAttribute(true)]
public int ContadoraAvrAvr()
{
    _Counter  ;
    return _Counter;
}

But when I try to consume it in a C# console project I receive the error No overload for method takes 0 arguments. But my method does not need any arguments.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsumeBasicCustomService.ContadoraServicioGrupo;

namespace ConsumeBasicCustomService
{
    class Program
    {
        static void Main(string[] args)
        {
            ContadoraServicioClient contadoraServicioVar;
            
            contadoraServicioVar.ContadoraAvrAvr();

            Console.WriteLine();
            Console.ReadLine();

        }
    }
}

  • Suggested answer
    Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    RE: no overload for method takes 0 arguments, in a method which does not need an argument

    If you don't want to provide any parameters, you can simply create a new, empty CallContext:

    contadoraServicioVar.ContadoraAvrAvr(new CallContext());

    If you want to set some values, you need to create an instance of CallContext and set its properties. This example is copied from AX documentation:

    // Create an instance of the CallContext class.
    CallContext context = new CallContext();
    
    // Set the value for Company.
    context.Company = "dat";
    
    // Set the value for LogonAsUser.
    context.LogonAsUser = @"yourdomain\userid";
    
    // Set the value for language.
    context.Language = "en-us";

    You could also use different syntax for the same thing:

    // Create an instance of the CallContext class.
    CallContext context = new CallContext
    {
        Company = "dat",
        LogonAsUser = @"yourdomain\userid",
        Language = "en-us"
    };

    Then you'll pass the object to your method:

    contadoraServicioVar.ContadoraAvrAvr(context);

  • Daniel Mora Profile Picture
    148 on at
    RE: no overload for method takes 0 arguments, in a method which does not need an argument

    Hi Martin,

    I understand now that I need a CallContext object, however I dont know exactly how I should code this based on what I have.

  • Suggested answer
    Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    RE: no overload for method takes 0 arguments, in a method which does not need an argument

    What would likely help is knowing what parameters the method actually expects, which you can easily see in Visual Studio, e.g. by typing contadoraServicioVar.ContadoraAvrAvr( and checking IntelliSense.

    You'll find that the methods needs a CallContext object.

    As you see, the parameter profile of the service operation and the method in the proxy class don't have to be identical.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans