Skip to main content
Community site session details

Community site session details

Session Id :

Switch statement and CLR enums

Volodymyr Giginiak Profile Picture Volodymyr Giginiak
There is a really weird bug in AX 2009 with CLR enumerations. If the code has "if" statement that validates value of a variable of CLR enum type everything is fine. However, the same "switch" statement fails with kernel exception.
Example:

MyNamespace.MyEnum enum;

enum = MyNamespace.MyEnum::Value1;

if (enum == MyNamespace.MyEnum::Value1)
{
    info("Everything is fine");
}

switch (enum)
{
    case MyNamespace.MyEnum::Value1 :
        info("And not so good here");
        break;
}

Result:
Error executing code: Wrong argument types for comparison.

This was originally posted here.

Comments

*This post is locked for comments