Category Archives: CIL

The best way to pass records to a class

This is the best method to pass the selected records from a Form to a Class

static void Main(Args args)
    MultiSelectionHelper    multiSelectionHelper;
    AssetTable              AssetTable;

    multiSelectionHelper = MultiSelectionHelper::createFromCaller(args.caller());
    assetTable  = multiSelectionHelper.getFirst();
    while (assetTable)
        assetTable = multiSelectionHelper.getNext();

MultiSelectionHelper class helps to iterate into selected records.
If you are using args object on your target class consider to use the method:


AX2012 R2: Failed to create a session

I retrive in AX2012 R2 the foolowing error when I sync the DB or when I try to load a queque of batch jobs:

Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics

A closer look into this learned that this is linked to the new partitions feature.

It seems the UserInfo table is not correctly updated and the partition administrator is not updated correctly when you restore an existing DB or the Demo database.
To fix this, you can do the following.

Stop the AOS
Restore the database again
Start the AOS
Start a client and complete the partition initialiasation checklist
Close the client and execute the script below on the SQL database
Restart the client and reimport your license (if you were restoring the Microsoft demo data, the demo license is back in there)
Then compile / generate CIL / DB sync and you should be on track again!
The script for updating the UserInfo inforation is as follows:

Error when generating CIL on AX 2012

When you run a Full CIL or an Incremental CIL and the system returns this error:

CIL generation: The given key was not present in the dictionary

You must navigate this path: C:Program FilesMicrosoft Dynamics AX60Server<AOS ISTANCE NAME>binXppIL

and open the file: Dynamics.Ax.Application.dll.log

here you can see error like this:

Finished pass 1 at 28/10/2013 09:12:55
Error when loading the method. Type: TaxSalesShippingBill_IN, Method: new
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary

Now you must correct all exceptions and recompile the objects