Unable to cast object of type ........

Hi all,

I get an error in AX when I run code to CIL. If I run the same code in std. X++ there is no Problem. The CIL dll is deleted and a Ful CIL was running over the Weekend but the error is the same.

Unable to cast object of type ‘Dynamics.Ax.Application.InventMov_Purch’ to type ‘Dynamics.Ax.Application.InventMov_KanbanJob_Process’

Has anyone an idea what there will be happen?

Thanks

InventMov_Purch doesn’t inherit from
InventMov_KanbanJob_Process, therefore the cast is invalid. I get a compilation error even in X++ if I try such an assignment.

AX doesn’t check types properly in some cases, therefore it’s sometimes possible to run even things that should be rejected due to type incompatibility (.NET runtime is stricter). That’s probably what’s happening in your X++ code.

You’ll have to change your code to use compatible types.