Tuesday, 12 April 2016

Consuming NEW Dynamics AX (AX 7) Business Logic from outside AX

Many a times, we come across with this - accessing AX Business logic from a Third-party application.  I assume that to be C# for this blog.  There exists different ways doing this.

  1. We can create Public Data Entities inside AX and consume the same thru OData Endpoints.  
  2. We can create Services inside AX and consume the same by adding Service References.
  3. We can add reference to the AX7 DLL and consume the respective business logic.  

I'm focusing on the #3 in this blog.

In AX 2012, this can be achieved using the DLL Microsoft.Dynamics.AX.ManagedInterop.  But this is not the case with AX7.  As every model that we create leads to assemblies, we need to directly add reference to the respective assemblies.  For example, Microsoft ships AX7 with Fleet Management module.  If we need to get access to a table in Fleet Management module, say "FMRental" from a .NET application, then the following DLLs needs to be referenced in the Visual Studio Project.

  • Dynamics.AX.FleetManagement
  • Microsoft.Dynamics.AX.Xpp.Support
  • Microsoft.Dynamics.AX.Xpp.AxShared

The DLLs Microsoft.Dynamics.AX.Xpp.Support and Microsoft.Dynamics.AX.Xpp.AxShared can be found in the C:\Packages\Bin folder.

Let say, you have upgraded your solution from AX 2012 to AX7 and the upgraded model is residing under the ApplicationSuite folder.  Then, you will need to add reference to the Dynamics.AX.ApplicationSuite DLL.

Here is the simple code example that calls the "CustomerName" method of the FMRental table,













Thanks!




4 comments:

  1. Greetings Abdul

    My code compiles, but i get the following error when trying to run, have you experienced this?

    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.

    ReplyDelete
    Replies
    1. My Apologies, i fixed this by allowing 32-bit Applications in my IIS Application pool settings, I now receive the following error: Additional information: The type initializer for 'Dynamics.AX.Application.FMRental' threw an exception.

      Delete
    2. This comment has been removed by the author.

      Delete
  2. Hi Abdul,

    I want to access some of the ISV tables of AX7 into my csharp class library project, I am not getting what library do I need to refer.
    As this are ISV tables do they have any dll like a Dynamics.AX.FleetManagement.dll?

    ReplyDelete