I have an X++ method (residing in the Fleet Management module) that I need to call within a C# class library.
I have used the below link as a guide -> https://ax.help.dynamics.com/en/wiki/writing-business-logic-in-c-and-x-source-code/
Basically, I have a c# console application, and I am making a call to this ax method as below
using Dynamics.AX.Application; using Microsoft.Dynamics.Ax.Xpp; class Program { static void Main(string[] args) { DFM_H5PortalSerializer axClass = new DFM_H5PortalSerializer(); axClass.processString("test"); }
}
The ax Class is shown in intellisense, however, as soon as I run it, i get the following exception:
"An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'Dynamics.AX.FleetManagement, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."
Any ideas on what is causing the issue and how to solve it?
Thanks
*This post is locked for comments
Yes, if you want a console application talking to Dynamics AX, you need a web service.
Don't forget that production environments of Dynamics AX run in Azure, so how else could your console application talk to them?
Thanks for you reply Martin. So basically, I would need to use a JSON or SOAP service instead to expose functionality to my c# console application..
You can't just call AX code from outside Dynamics AX, such as in your console application.
But you can write C# code (there you can refer to AX types) and execute it from Dynamics AX, which is what the wiki talks about.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156