Hey guys,
I need a data structure that allows me to do usual and reversal iteration, so I am using the System.Collections.ArrayList to store elements from my FBGiaRecordChildren_BR class .
My code is running on IL and I am having a Casting problem while trying to do this:
FBGiaRecordChildren_BR recordChildren;
int i, size;
size = recordChildrenList.get_Count();
for( i = size-1 ; i >= 0 ; i--)
{
recordChildren = recordChildrenList.get_Item(i);
if (recordChildren.getRecord() == _parentType)
{
return recordChildren;
}
}
Error: System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.AX.ManagedInterop.Object' to type 'Dynamics.Ax.Application.FBGiaRecordChildren_BR'.
I've already tryed to use CLRInterop::getAnyTypeForObject, but doesn't help me:
FBGiaRecordChildren_BR recordChildren;
CLRObject obj;
int i, size;
size = recordChildrenList.get_Count();
for( i = size-1 ; i >= 0 ; i--)
{
recordChildren = recordChildrenList.get_Item(i);
recordChildren = CLRInterop::getAnyTypeForObject(obj);
if (recordChildren.getRecord() == _parentType)
{
return recordChildren;
}
}
I would be very thankful if anyone could help me.
Thanks a lot!