In a typical fashion, Microsoft spent a lot of effort integrating a variety of it's new technologies in Dynamic AX 4 (nee Axapta). Often these additions are of questionable benefit to the end-user/customer -- but, the ability to make direct calls to the .NET/CLR from AX's built in X++ language is pretty handy for the developer.
The process is pretty simple. Add a reference in the AOT to your CLR assembly -- or a reference to .NET's "System" namespace is already available. Assert permissions to access the bridge (just a wrapper for Window auth), then make your calls.
You declare your variables in their native CLR types, and use the methods of the CLRInterop class in AX to caste to AX data types. Here's an example to build an AX container of file names in a directory, something trivial in .NET that's actually a bit of a pain with AX's limited built in file/directory methods.
-
void buildFileList( str _folder )
-
{
-
InteropPermission perm = new InteropPermission( InteropKind::ClrInterop );
-
container fList;
-
System.Array dirList;
-
int ix;
-
;
-
-
perm.assert();
-
-
dirList = System.IO.Directory::GetFiles( _folder );
-
for( ix=0; ix <ClrInterop::getAnyTypeForObject( dirList.get_Length() ); ix++ )
-
{
-
fList = conins( fList, conlen(fList)+1, ClrInterop::getAnyTypeForObject( dirList.GetValue(ix) ) );
-
}
-
return fList;
-
}
Dear,
I need X++ book.
Do you can help me?
Rgds,
Hendra
Is there any way to place .Net Usercontrol on a form inside AX??