I have an MS Dynamics AX 2012 project and I am using .Net interop.
There is a C# method inside a static class called Database:
public static List<String> GetAllDatabases(string dataSource)
After referencing this assembly, I can execute in X++:
ADOMD.ADOMD.Model.Database::GetAllDatabases();
But I can’t read the string list that it’s returning.
I would like to use something like:
List databaNameCollection = new List( Types::String );
;
databaNameCollection = ADOMD.ADOMD.Model.Database::GetAllDatabases();
But it trows an error:
Error executing code: (object) has no valid runable code in method 'GetSID'.
How could I do it?
——-EDITED——
I found this post:
http://blogs.msdn.com/b/x/archive/2010/01/19/traversing-elements-in-an-ienumerable-from-x.aspx
But it was in 2010, probably for AX 2009, I tried to assign:
ClrObject enumerator;
str theValue;
;
enumerator = ADOMD.ADOMD.Model.Database::GetAllDatabases();
while (enumerator.MoveNext())
{
theValue = enumerator.get_Current();
print theValue;
}
The GetallDatabases method is working with another .Net project, it is returning 10 objects, but at the X++ code, is returning nothing.
Thanks
To answer your question about .NET types in X++ and
get_{x}andset_{x}:.NET properties are shown in X++ as methods. For example, the get & set property below in C#
will show in X++ as
Basically C# properties are just syntactic sugar. The C# compiler will create a get_{x} method for each get property and a set_{x} for each set property.
In your case, if you want to access the
Nameproperty in the cubeDef object you would have to write something like this in X++: