Tuesday, January 07, 2014

AX2012 R2 RunAs and Global::RunClassMethodIL

Just a quick note on using RunAs in AX2012: The static method being called by RunAs should have a container parameter in the method declaration. Otherwise, system will complain that the static method was not found. So:
// This would fail with static method not found error.
public static void methodWithoutParm()

// This would work!
public static void methodWithContainerParm(container _c)
In fact, the same can be said to Global::RunClassMethodIL. However, the error throw by Global::RunClassMethodIL is more helpful. It'll complain that the parameter passed into the static method is incorrect. Seeing that a third parameter of type container is mandatory for Global::RunClassMethodIL, it's easier to get the idea to try adding the container parameter in the target static method. =]
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment