Passing a list of objects to .net

Hello all:

I have a .net class with a public method as follows

public List getOrder(List)

Where customer is a class object.

When calling getOrder() from AX what is the parameter type that is compatible with list ?

I have tried

List = new List(Types::Class/Container/Anytype)

Arrays and ClrObject

Let me know if anyone has the answer to this.



X++ List class and .NET List class are two completely different things and there is no automatic marshalling between complex types at all. It’s also really difficult to work with generic types in AX - you’ll make your life much easier if you change that to non-generic types. You can still use generics inside your solution, you just want to simplify the interface with AX.

I don’t say it’s completely impossible to use generic types, but it’s cumbersome and error-prone. Check the example:

System.Type listType = System.Type::GetType('System.Collections.Generic.List`1[System.String]');
CLRObject list = System.Activator::CreateInstance(listType);

.NET Interop is also slightly different in each version of AX, so don’t forget to mention your version if you have additional questions.

Thanks Martin. My version is AX 2009.

The example you mentioned is for Strings.

What I would like is to populate the list with objects.

For Example

List.add(new MyClass());

My .net class is

public List getOrder(List)

I used string because I know nothing about your class and the usage is very similar with any types.

List.add(new MyClass()); is basically what you can use, just be sure that you use the fully qualified name of your .NET class, e.g. List.add(new MyNamespace.MyClass());. You would have to replace the string in GetType() too, but instead of that, get rid of generics in your public interface and create a non-generic collection simply by calling its constructor.

Hello Martin:

This solution does not work for me. I am in VS2008.

My .NET method

public void CallMethod(List test)


System.Type listType = System.Type::GetType(‘System.Collections.Generic.List`1[System.String]’);

list = System.Activator::CreateInstance(listType);



does not compile. I see the CallMethod in the intelli dropdown but does not compile.

Any suggestion will help. Or anyother solution using non generic type will be greatly appreciated.


I told you that you would just complicate your life by trying to use generic types from X++. I repeat it again: don’t do that! Use a non-generic parameter, therefore change your method to CallMethod(ArrayList test), CallMethod(IEnumerable test) or something.

The example I gave you was intended just to show that it’s technically possible to find workarounds for generic types even though they’re not supported by X++, but that doesn’t mean that you should do that. By the way, the call to a method with a generic parameter would compile and run in AX2012, but even there it’s better to use non-generic types.

Eureka! Thank you. This helped.