How to: Compile and Run X++ that Calls CLR Managed Assemblies
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
When you write X++ code that calls into an assembly that is managed by the common language runtime (CLR) of the .NET Framework, you must make sure that the X++ compiler can find the assembly.
How CLR Managed Assemblies are Found by the X++ Compiler
If your X++ code calls the .NET Framework class System.String, the X++ compiler finds the managed assembly because of two system configurations:
In the Application Object Tree (AOT), there is a reference under the References node to the assembly that contains the class.
The assembly is in the Global Assembly Cache.
The installation of Microsoft Dynamics AX includes references to some of the commonly needed .NET Framework assemblies.
Referencing Your Assemblies
If your X++ code calls into a CLR managed assembly that you wrote, you must follow these steps.
To compile on the client
Copy your assembly into the client\bin\ directory under your Microsoft Dynamics AX installation directory.
Your full path might resemble C:\Program Files\Microsoft Dynamics AX\version\client\bin\.
In the AOT, right-click References, and then click Add Reference.
Click the Browse button.
In the Select file dialog box, select your assembly file. Click Open.
Running on a Tier that Has Your Assembly
Your X++ code might be unable to run on the Application Object Server (AOS) tier, even though your X++ code compiles successfully on the client. A copy of each assembly that is needed by your X++ code must exist on the AOS computer for your X++ code to run on the AOS tier.
To run your X++ code on the AOS tier, you must copy your assembly to the server\...\bin\ subdirectory on the AOS computer. This is located under the Microsoft Dynamics AX installation directory.
It is not required to provide any reference to the assembly because the X++ code is already compiled.
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.