Currently, I am using the following code:
Axapta ax = new Axapta();
string tableName;
ArrayList ax_cont = null;
ax.Logon(null, null, null, null);
try
{
ax_cont = (ArrayList)ax.CallStaticClassMethod("Code_Generator", "tableNames");
for (int i = 1; i <= ax_cont.Count; i++)
{
tableName = ax_cont[i].ToString();
tablesCB.Items.Add(tableName);
}
}
catch { }
But I'm getting a type conversion exception.
What do I need to do in C# when a list is returned from ax dynamics as an AxpataObject
?
It depends on what
Code_generator::tableNames()
returns.It certainly does not return an
ArrayList
but most likely an AXList
, and the two are not the same and cannot be casted.One way would be to let AX return a container, then access that.
Otherwise you could access the AX
List
directly using AxaptaObject