Quantcast
Channel: Martin Dráb's Activities
Viewing all articles
Browse latest Browse all 17532

A strange error when code is running on batch (CIL). It works fine when code is interpreted (X++)

$
0
0

Hello,

I have a strange problem with a standard ax functionality.
The problem is that when the code is running as CIL (in batch) the following exception was thrown:

Unable to cast object of type 'System.Object[]' to type 'Microsoft.Dynamics.Ax.Xpp.Common.

Here is the source:

class SomeClass
{
    List scheduleLines
}

public void new()
{
    scheduleLines = new List(Types::Container);
}

protected void addToList
{
    SalesQuotationLine salesQuotationLine;

    while select salesQuotationLine
        where salesQuotationLine.QuotationId == xxxx
    {
        scheduleLines.addEnd([salesQuotationLine]);
    }
}

protected SalesQty totalQty()
{
    SalesQty            qty;
    SalesQuotationLine  salesQuotationLine;
    ListEnumerator      scheduleLinesEnumerator = scheduleLines.getEnumerator();

    scheduleLinesEnumerator.reset();
    while (scheduleLinesEnumerator.moveNext())
    {
        salesQuotationLine = scheduleLinesEnumerator.current();
        qty += salesQuotationLine.SalesQty;
    }

    return qty;
}

The line that throws the exception is in method totalQty().

Here is it:

salesQuotationLine = scheduleLinesEnumerator.current();

Does anyone faced such a problem?

Thanks.


Viewing all articles
Browse latest Browse all 17532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>