Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

Thursday, April 11, 2013

Solving the error " The CIL generator found errors and could not save the new assembly"

 

Hi There!

On this post I would like to discuss how to solve the CIL compilation error when deploying services for the first time in AX 2012. I have been working on a newly installed AX 2012 CU2 instance this week, and I deployed both basic and enhanced services.

This action was successfully done and I did not experience any issues. However, when I created a new service group and I deployed it, I encounter an error saying “The CIL generator found errors and could not save the new assembly”.



Now, this instance of AX 2012 is using a restored DB backup from another instance as I needed some data and objects already existing. It makes sense to think that this issue is true from the premise that I never went through a full AX and CIL compilation.

In addition, when generating the services through the installation, the references to the .NET Module File and the AX Application DLL were correct, but where they referring to the correct .NET Assembly types for the WFC generated endpoints?  I truly don’t know the answer to this and I asked for help.

My friend Bill Bartolotto (you can contact him here at his LinkedIn profile) went through this problem and he helped me solved it in my instance.  Bill has a vast experience in AX architecture and is really knowledgeable in AX 2012.

So, how do we fix this problem?

Step 1: Stop the AOS

Atep 2: Delete all of the source in the C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\XppIL directory

When you do this, just delete all the files within the XppIL folder that are outside of other folders. Make a backup just in case, and the files would be generated while the full compilation is taking place.



Step 3: Start the AOS



Step 3: Perform a full compile (it will not work without doing this)



Step 4: Perform a full CIL generation



The drawback of this fix is that it takes a long time to complete. However, this fixes the issue, which is the desired outcome, and the services deployment and incremental CIL compilations moving forward would be error free.

As you can see, the service was deployed correctly and if I opened my inbound port I'll see it there.



UPDATE:

After a FULL CIL compilation I got the following errors:

 
AOT > Class> ReleaseUpdateDB41_Basic
 
 
I just went to the object in question and compiled them separately.

 
 
The outcome would correctly compiled all the artifacts, including my new service gorup.



Until the next post!

Friday, August 10, 2012

Working with the LedgerGeneralJournalService AX 2012



Hi There!

I hope everyone had a good week and that you are ready for an excellent weekend.

As you may well be aware by now, in AX 2012 you can import data by using services. You can use these services to import Customers, GL transactions, Products, etc.

You can learn more about services and AIF in one of my posts called Microsoft Dynamics AX 2012 Services and (Application Integration Framework) AIF architecture , and you might want to take a look into Services and Application Integration Framework .

On this post, I would like to share with you some code to import GL transactions into AX 2012 using the LedgerGeneralJournalService available in AX 2012.


static void ImportGLTransWithLedgerGeneralJournalService(Args _args)
{

    // Set these variables.
    LedgerJournalNameId                     journalName = 'GenJrn';
    SelectableDataArea                        company = 'CEU';
    TransDate                                     transactionDate = 10\10\2012;

    str                                     line1MainAccount = '256369';
    str                                     line1FullAccount = '256369--';
    str                                     line2MainAccount = '400090';
    str                                     line2FullAccount = '400090-10-';
    str                                     line2Dimension1Name = 'BusinessUnit';
    str                                     line2Dimension1Value = '10';


    LedgerGeneralJournalService             ledgerGeneralJournalService;
    LedgerGeneralJournal                       ledgerGeneralJournal;

    AfStronglyTypedDataContainerList              journalHeaderCollection;
    LedgerGeneralJournal_LedgerJournalTable   journalHeader;
    AifEntityKeyList                                         journalHeaderCollectionKeyList;
    RecId                                                       journalHeaderRecId;


    AfStronglyTypedDataContainerList                   journalLineCollection;
    LedgerGeneralJournal_LedgerJournalTrans       journalLine1;
    AifMultiTypeAccount                                       journalLine1LedgerDimension;
    LedgerGeneralJournal_LedgerJournalTrans       journalLine2;
    AifMultiTypeAccount                                       journalLine2LedgerDimension;
    AifDimensionAttributeValue                             journalLine2Dim;
    AfStronglyTypedDataContainerList                   journalLine2DimCollection;
    ;

    ledgerGeneralJournalService = LedgerGeneralJournalService::construct();
    ledgerGeneralJournal = new LedgerGeneralJournal();

    // Create journal header.
    journalHeaderCollection = ledgerGeneralJournal.createLedgerJournalTable();
    journalHeader = journalHeaderCollection.insertNew(1);
    journalHeader.parmJournalName(journalName);

    // Create journal lines.
    journalLineCollection = journalHeader.createLedgerJournalTrans();
    // Line 1
    journalLine1 = journalLineCollection.insertNew(1);
    journalLine1.parmLineNum(1.00);
    journalLine1.parmCompany(company);
    journalLine1.parmTransDate(transactionDate);
    journalLine1.parmAccountType(LedgerJournalACType::Ledger);
    journalLine1.parmTxt('AX Wonders Journal Import test');
    journalLine1.parmAmountCurDebit(235.00);

 
    // Define Ledger Dimensions
    journalLine1LedgerDimension = journalLine1.createLedgerDimension();
    journalLine1LedgerDimension.parmAccount(line1MainAccount);
    journalLine1LedgerDimension.parmDisplayValue(line1FullAccount);
    journalLine1.parmLedgerDimension(journalLine1LedgerDimension);


    // Line 2
    journalLine2 = journalLineCollection.insertNew(2);
    journalLine2.parmLineNum(2.00);
    journalLine2.parmCompany(company);
    journalLine2.parmTransDate(transactionDate);
    journalLine2.parmAccountType(LedgerJournalACType::Ledger);
    journalLine2.parmTxt('AX Wonders Journal Import test');
    journalLine2.parmAmountCurCredit(500.00);
    journalLine2LedgerDimension = journalLine2.createLedgerDimension();
    journalLine2DimCollection= journalLine2LedgerDimension.createValues();

    journalLine2Dim= new AifDimensionAttributeValue();
    journalLine2Dim.parmName(line2Dimension1Name);
    journalLine2Dim.parmValue(line2Dimension1Value);
    journalLine2DimCollection.add(journalLine2Dim);

      // Define Ledger Dimensions
    journalLine2LedgerDimension.parmAccount(line2MainAccount);
    journalLine2LedgerDimension.parmDisplayValue(line2FullAcct);
    journalLine2LedgerDimension.parmValues(journalLine2DimCollection);
    journalLine2.parmLedgerDimension(journalLine2LedgerDimension);


    // Insert records.
    journalHeader.parmLedgerJournalTrans(journalLineCollection);
    ledgerGeneralJournal.parmLedgerJournalTable(journalHeaderCollection);
    journalHeaderCollectionKeyList =
        LedgerGeneralJournalService.create(ledgerGeneralJournal);

    journalHeaderRecId =
        journalHeaderCollectionKeyList.getEntityKey(1).parmRecId();

    info(strFmt("LedgerJournalTable.Recid = %1", int642str(journalHeaderRecId)));

}



That's all for now folks!



Thursday, January 5, 2012

Ax 2012 AIF Calling the CustCustomerService.Create method from WCF

A fellow AX developer wrote a very interesting article about creating a customer using the CustCustomerService.Create method from WFC.

You can access the post here.

Take care!