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 :
Finance | Project Operations, Human Resources, ...
Answered

SET LIST OF C# .NET 3,5 DLL FROM AX 2009 X++

(0) ShareShare
ReportReport
Posted on by 10

Hello, I am working with some webservice call and I have a C# List of object which am to set from x++.

This code is assembled on the .net Framework 3.5, the code I have in C# is:

public List<PurchLine>  line { get; set; }      

private List<PurchLine> lineList = new List<PurchLine>();        

        public void AddLine(PurchLine line)

        {

            lineList.Add(line);

        }

        public List<PurchLine> GetLine()

        {

            return lineList;

        }

On the other hand, in AX 2009,

I have created a class in X++ to call this code. My problem is that when working with the Purchline list, I don't perform the Set_Line() method. Mi code is :

.....

while select purchLine
where purchLine.PurchId == purchTable.PurchId
{

d365PurchLine = new FinishProductAgainstOrder.PurchLine();

d365PurchLine.set_lineNum(num2str(purchLine.LineNum, 6, 2, -1, -1));
d365PurchLine.set_itemId(purchLine.ItemId);


d365purchTable.AddLine(d365PurchLine);

}

d365PurchTable.set_line(d365PurchTable.GetLine());


resultDirmemo = d365PurchTable.Serialize(d365PurchTable);

......

3005.Captura-de-pantalla-2022_2D00_04_2D00_07-a-las-21.58.46.png

The error shown by the system is that the method I want to use does not exist.

Can you help me?

Thanks

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,084 Most Valuable Professional on at

    Because .NET Interop from X doesn't support generic types, you'll make your life much easier if you don't expose generic types in your C# code. For example, create a concrete type (e.g. PurchLineList) instead of using List<T>, or use a non-generic collection (ArrayList,  IList).

    If you insist on using generic types anyway, try assigning the value through a CLRObject variable.

    CLRObject lineList = d365PurchTable.GetLine();
    d365PurchTable.set_line(lineList);

    By the way, please always use Insert > Code (in this rich formatting view) to paste source code to this forum. It'll be much eaiser to read.

  • jgimenez Profile Picture
    10 on at

    Hello Martin.

    Thank you very much for the quick response, I really appreciate it.

    I have tried what you have advised me and with the non-generic collection (Ilist) I still had problems adding the PurchLine object inside the list.

    Anyway, in the end declaring in my X++ code a CLRObject variable to assign the value to, it worked perfectly.

    Finally, sorry for miscopying the text in the forum, it's the first time I'm writing and I didn't know about it, I'll keep in mind next time your tip when copying source code in the forum.

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

    If the type of "list" variable is something like ILIst, you'll be able to replace CLRObject with such a type.

    No worries about code formatting. It's normal that you don't know all the features from the beginning - it's exactly why I point to it. :)

    Another important thing is that if you get an answer, you should verify it. It'll make clear what the question has already been answered and what the answer was. It'll help other users of this forum; e.g. they can easily navigate to answers and skip the rest of discussion. See details in Suggested and Verified Answers.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 455 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 308 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans