Using and Interacting with CLR Data Types

It is possible to use CLR data types inside AX. The requirement arises when we use CLR classes and framework inside AX for any of our use.

One thing to note regarding them is marshaling. When you use CLR data types, you cannot directly use them in AX constructs you need to marshal them to AX data type and use them.

Below is an example of once such job:

static void xppCLRDataTypeInterOp(Args _args)


    System.String[] retString; //.Net Data Type

    System.Int32    netI;      //.Net Data Type

    int len;

    int i;


    //Test function to initialize and return a .Net string array

    System.String [] getStringArray()


        System.String[] myString;



        myString = new System.String[2]();

        myString.SetValue("Test", 0);

        myString.SetValue("Hello", 1);

        return myString;





    //Get and store the array in a .Net Data Type string array

    retString = getStringArray();


    if (retString)


        //Get the length and store it in .Net Int32

        netI = retString.get_Length();


        //Marshal .Net to X++

        len = netI;


        //Loop and display the string

        for( i = 0 ; i < len ; i++)






Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s