Friday, December 29, 2017

Illegal entry in an array.

I have an issue that is returning a very strange error from Enterprise Portal.
Initially I receive the following in my browser:

An unhandled error has occurred. To view details about this error, enable debugging in the web.config file or view the Windows event logs.

Upon checking the event viewer on the EP IIS machine, I see the following:

An unhandled error has occurred. To view details about this error, enable debugging in the web.config file or view the Windows event logs.

Error executing code: Illegal entry in an array.

Stack trace

(C)\Data Dictionary\Tables\myTable\Methods\label - line 34


Microsoft.Dynamics.AX.ManagedInterop

   at Microsoft.Dynamics.AX.ManagedInterop.Record.CallWithReturnType(String methodName, Type returnType, Object[] paramList)
   at Microsoft.Dynamics.Framework.BusinessConnector.Session.DynamicsRecordAdapter.Call(String methodName, Object param1)

As of this writing, I have no idea what 'Illegal entry in an array' means.

Stay tuned...

UPDATE
Temporary Solution:
Well, I couldn't find a good solution for this. So here is the work around.
Original code throwing the error:

return mytable.myFieldArray[_arrayIndex];

Instead I do:

switch (_arrayIndex)
    {
        case 1:
            retValue = this.AttrFieldLabel[1];
            break;
        case 2:
            retValue = this.AttrFieldLabel[2];
            break;
        case 3:
            retValue = this.AttrFieldLabel[3];
            break;
        case 4:
            retValue = this.AttrFieldLabel[4];
            break;
    }

return retValue;

Hardcoding the index numbers on the array call seems to have solved my issue for now.

Happy coding!

No comments:

Post a Comment