Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : TwKi2rO2UQn78PQZOZV/kj
Microsoft Dynamics AX (Archived)

Call classes/method in DLL from X++

Like (0) ShareShare
ReportReport
Posted on 8 Feb 2015 14:40:24 by 395

Hi

I have a DLL (written in C#) with several methods  that I need to call from X++. I have created a reference in the AOT to the DLL but when I try to use it in the X++Class. Intellisense does not have the classes or methods available an options.

No matter what I try, X++ does not recognise the classes or methods.  Is there something other than setting the references that I need to do?

Regards

Lourens

*This post is locked for comments

  • Lourense Profile Picture
    395 on 08 Feb 2015 at 16:40:34
    RE: Call classes/method in DLL from X++

    Thank you Lulian, your help is much appreciated.

    It is working now.

    Lourens

  • Verified answer
    Iulian Cordobin Profile Picture
    8,201 on 08 Feb 2015 at 16:30:19
    RE: Call classes/method in DLL from X++

    You've declared your methods static, so the right call would be

    x =  Calcs.Operations::add(a, b);

  • Lourense Profile Picture
    395 on 08 Feb 2015 at 16:14:15
    RE: Call classes/method in DLL from X++

    Hi Lulian

    I have done what you suggested and it compiled without a problem. It also showed up in Intellisense.

    I then added a method Main with the following code:

    private void main()

    {

       int x;

       x=test.add(1,2);

    }

    I then get an error: The method add has not been declared.

    My only remaining problem is that I can not call the method "add".

    Any suggestions?

    Lourens

  • Iulian Cordobin Profile Picture
    8,201 on 08 Feb 2015 at 15:46:22
    RE: Call classes/method in DLL from X++

    Yes, it's much clearer, however, I am not sure why it's not working. All you did is fine.

    Can I suggest, just close again the AX client completely (both the client and development workspaces), and after reopening it, just compile the class in the AOT tree, without actually opening the class's code.

  • Lourense Profile Picture
    395 on 08 Feb 2015 at 15:23:31
    RE: Call classes/method in DLL from X++

    Thank you for getting back to me Lulian

    The location of the DLL is in "C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin"

    I have restarted the Client

    I do not see in Intellisense and the code does not compile

    I used >NET Framework 4.0.30319

    using System;

    namespace Calcs

    {

       public class Operations

       {

           public static int add(int a, int b)

           {

               return a + b;

           }

           public static int substract(int a, int b)

           {

               return a - b;

           }

           public static int multiply(int a, int b)

           {

               return a * b;

           }

       }

    }

    I compiled it to C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\calcs.dll

    from the command line using

    C:\Windows\Microsoft.net\Framework\v4.0.30319\csc.exe /target:library /out:calcs.dll calcs.cs

    I then created a reference in the AOT to C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\calcs.dll

    I restarted the AOS and then in X++ I tried:

    class aaTest

    {

       Calcs.Operations test;

    }

    Calcs.Operations is then underlined and it will not compile.

    I hope the above makes it a bit more clear.

    Lourens

  • Iulian Cordobin Profile Picture
    8,201 on 08 Feb 2015 at 14:47:05
    RE: Call classes/method in DLL from X++

    What is the dll location (GAC, client's Bin folder, other location on hard drive)?

    Have you restarted the client after adding the reference?

    Are you declaring your variables using the fully qualified namespace names?

    You have a problem with the only the Intellisense or is the code not compiling?

    What .Net framework was used to build the dll?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February 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... 293,280 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,044 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading started