web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Use class library with async method

(1) ShareShare
ReportReport
Posted on by

I 'm using class library and I'm sending http request, of course it's asynchronously. I used Task class to make it synchronous. I tested class library from console app and it was working fine, but when I tried t call that same method from AX it's not returning response, I mean it's working on and on and I need to close ax completely to stop the process. So what could be the problem and how can I solve it?

*This post is locked for comments

I have the same question (0)
  • JonathanDries Profile Picture
    35 on at

    Have you been able to solve this issue? I am facing the same issue on an AX2012 environment.

    Calling the code from the console app did the trick, but running it from AX resulted in a hanging client (however the call was succesfully, and i receive the expected result) so no result is given back to AX

  • Community Member Profile Picture
    on at

    [quote user="Mikheil Tsiklauri"]

    I 'm using class library and I'm sending http request, of course it's asynchronously. I used Task class to make it synchronous. I tested class library from console app and it was working fine, but when I tried t call that same method from AX it's not returning response, I mean it's working on and on and I need to close ax completely to stop the process. So what could be the problem and how can I solve it?

    [/quote]

    We face exactly the same problem. We created a .net class as a bridge to send messages to kafka.

    The message is delivered perfectly, but the client hangs totally.

    Was somebody able to fix that issue?

  • nmaenpaa Profile Picture
    101,162 Moderator on at

    Are there any more details that you think could be useful in troubleshooting it?

    For example your code? 

  • Community Member Profile Picture
    on at

    Yes, of course.

    We have two kafka broker incl. one zookeeper running.

    AX-Code:

     

    static void KafkaTestJob(Args _args)
    
    {
    
        System.String[] strAr;
    
        str json;
    
        strAr = new System.String[2]();
    
     
    
        strAr.SetValue("http://xxx:9092",0);
    
        strAr.SetValue("http://yyy:9092",1);
    
        json = "{\"itemId\":\"axTestitem\",\"available\":\"true\"}";
    
     
    
        new InteropPermission( InteropKind::ClrInterop ).assert();
    
     
    
        KafkaNet.MSAXInterface::InitKafka(strAr);
    
        KafkaNet.MSAXInterface::sendMessageToKafka("stockavailability",json);
    
     
    
        CodeAccessPermission::revertAssert();
    
    }
    Included DLL-File:

    kafka-net.dll

     
    The DLL is included in the bin directory of the client and the server and added as reference in AOT. (CIL was done after including)
     
    Code changes in kafka-net:
    Implemented a new class and methods with string-input-parameters because the standard methods need interface classes as input parameters. That’s not working in AX because the interfaces are .net-classes.
    Inside the kafka-net the code is running as an async task.
     
    The code is working and it's possible to send a message to kafka, but after that the ax-client freezes, so I have to kill ax via the taskmanager.
    Running the code just 'server side' didnt't help also.
     
     

     


  • nmaenpaa Profile Picture
    101,162 Moderator on at

    Maybe you could try to debug it with Visual Studio (when calling the DLL from AX) and see if you get any clue about what freezes.

  • Community Member Profile Picture
    on at

    If you can tell me how I'm able to debug a DLL which is included in AX from VS, I'm happy to try it :-D

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at
  • Suggested answer
    JonathanDries Profile Picture
    35 on at

    I managed to solve my problem by creating a new class that runs the dll and make the class to runs on server only. Dll bridge was made in visual studio (included vs project in AX and dll only deployed to server as code can only run server-side). When running the code it does wait now for the response

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans