pass string array from x++ to .net (Dynamics ax 2009 integration with .net)

i want to pass a string array from x++ to C# method. but it is giving an error : Argument ‘1’ is incompatible with required type.

X++ code:

public static server str callfunction()


MagentoTrigger.MagentoAXServiceSoapClient soapClient; // .net webservice object

str ret;

str arry[2];


arry[1] = “101”;

arry[2] = “102”;

new InteropPermission(InteropKind::ClrInterop).assert();

soapClient = new MagentoTrigger.MagentoAXServiceSoapClient(‘MagentoAXServiceSoap’);

ret = soapClient.Sync_Item_Selective(arry); // getting error : Argument ‘1’ is incompatible with required type

//method : string Sync_Item_Selective(string[] array)


return ret;


Sync_Item_Selective method takes “string array” as argument. but i am unable to pass string array from x++.

i have also tried with list, container. but i dont know how to use container in .net

plz suggest me, i just want to pass a string array to .net method.

There is no magical conversion between X++ arrays and CLR arrays - you’ll have to use the same type as the method expects. If it expects System.String[], your implementation should look like this:

System.String[] arry = new System.String[2]();
arry.SetValue("101", 0);
arry.SetValue("102", 1);

Just be sure that you look at the type of the service proxy, not the original .NET method. The types don’t have to be the same.

hello martin,

Error is gone now.

but when i m running my code, AOS is getting stopped everytime.

And on debugging, values(101 and 102) are not shown in Arry.

when i debug it,

getting error while processing : System.String[] arry = new System.String2;


Request for the permission of type ‘InteropPermission’ failed.


(S)\Classes\Event_Magento\callfunction1 - line 13

(C)\Classes\FormButtonControl\Clicked - line 56

You have to assign code access permissions (new InteropPermission(InteropKind::ClrInterop).assert()) before using .NET Interop.

thanks martin, now it is working perfectly :slight_smile: