Recently I was asked the question how it is possible to import a Dynamics AX XPO file to Dynamics AX from X++ code. This is actually possible using the SysImportElements class.

However this approach does not work if the XPO file should be imported in a Business Connector session. When the the import method of the SysImportElements is called in this scenario it fails with the following error message:

Image List Object is not initialized.

The classes used in this context were simply not designed to work in a Business Connector session, as several user interface elements are accessed that are not available with the Business Connector.

Instead of using the .NET Business Connector to import a XPO file the Dynamics AX Client can be called with command line parameters to automatically import a XPO file.

To import the XPO without compilation, run:

ax32.exe -AOTIMPORTFILE=c:\path\import.xpo -lazyclassloading -lazytableloading -minimize -nocompileonimport

To compile all the code, run:

ax32.exe -lazyclassloading -lazytableloading -startupcmd=CompileAll -minimize