web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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)

CodeAccessPermission::revertAssert();

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.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Kumar Gaurav @ MS Profile Picture
    on at

    Use a native .net array type by calling system class in your ax x++ code, build an array in native .net type and it should work.

    Something like System.Array myArray ;

  • Suggested answer
    Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at

    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);
    (…)
    soapClient.Sync_Item_Selective(arry);

    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.

  • Community Member Profile Picture
    on at

    @Martin,

    I´m facing the same problem and the solution ( use of System.String[] str = new System.String[2]() ) is not working, I have tried a lot and keep throwing the same error described by vibhor.

    @vibhor How u solved this issue?

  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at

    Jefferson, if it complains about incompatible types, it means that your method expects something else then an array of strings. Please look at the type of the parameter and provide an argument of the same or compatible type.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans