问题
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
?
回答1:
It depends on what Code_generator::tableNames()
returns.
It certainly does not return an ArrayList
but most likely an AX List
, 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
AxpataObject ax_cont = ax.CallStaticClassMethod("Code_Generator", "tableNames");
AxpataObject ax_it = ax_cont.Call("getEnumerator");
while (ax_it.Call("moveNext"))
// Hope you get it
来源:https://stackoverflow.com/questions/14495638/return-a-list-to-net-business-connector