Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2022 Release Wave 1 PlanDynamics 365 release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.
2022 release wave 1 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
Is it possible to subscribe from X++ to a C# event in Dynamics 365 Finance and Operations?
My goal is the following:
I have a project in C# that is responsible for receiving messages from an Azure queue service (Service Bus to be specific), the success would be that this application is always active listening to messages from the queue, receive them as JSON and send it to X++ for a specific process to continue.
Now let me explain my situation...
For compatibility issues with my X++ project, I must use the .NET Framework 4.6 in my C# project and with this version of .NET I was only able to download the Microsoft.Azure.ServiceBus Version 1.0.0 library (I know it's obsolete but It's the only one I could install.
This is the code I used to receive the messages Use Azure Service Bus queues with .NET (old version) - Azure Service Bus | Microsoft Docs
My main problem is determining how to send the information to X++ as it arrives in C#. Investigating, the most viable option seemed to me is using delegates and events, so I added the following to the documentation code.
And I modified the ProcessMessagesAsync method to add the event.
After this I created a console application (C#) to test it, this is the code.
I sent 3 messages to the queue and these were appearing in the test console application (it works perfectly).
I tried to replicate the exact same thing in X++, like this:
But it doesn't work, the process hangs and never shows me any message when I send data to the queue.
Something additional is that in the line queueListener.MessageReceived += eventhandler(MntServiceBusTest::ShowMsg), MessageReceived doesn't appear to me, the options that appear are
However, if I use add_MessageReceived I get that the C# class doesn't contain any delegates with that name and it won't let me compile the X++ project.
I hope someone can give me an idea of how to achieve my goal, I spent days with this situation.
What about subscribing to the event in C# and let the event handler call an AX method?
For example, your QueueListener class could have a property for a logger object, defined at an interface (e.g. ILogger). You'll implement the interface in an X++ class and pass an instance of this class to QueueListener. The event handler will then call a method for dealing with messages.
By the way, it could be interesting to see what CIL was generated for the case with += eventhandler. You can use a CIL decompiler for that - there is no decompiler back to X++, but you can decompile it to C# and see the logic there.
Business Applications communities