Catching exceptions in AX 7

In this blog post, I briefly recapitulate how to throw and catch exceptions in X++ and introduce a new way of handling CLR exceptions in AX 7. X++ exceptions When you want to throw an exception in X++, you typically do it by something like this: throw error("It’s broken!"); It’s a functional equivalent of adding a …

Continue reading ‘Catching exceptions in AX 7’ »

X++ to CIL: Object must implement IConvertible

Somebody asked in Dynamics User Group forum about an error thrown by RetailCommonWebAPI running in a batch in AX 2012 (RetailCommonWebAPI in batch mode). I don’t want to discuss that particular problem here, but I want to show the underlying cause, because it’s actually quite tricky. What I’m discussing below is related to CIL generated …

Continue reading ‘X++ to CIL: Object must implement IConvertible’ »

Tips for CIL debugging: Collection classes

In some cases, you can make your debugging much easier if you debug CIL instead of the original X++ code. Working with collection classes (lists, maps, etc) is such a case. For example, the following picture shows a map (mapping customer IDs to CustTable records, e.g. for caching) as displayed by the AX debugger: If …

Continue reading ‘Tips for CIL debugging: Collection classes’ »

Tips for CIL debugging: No variables displayed

Because AX 2012 sometimes executes CIL generated from X++ instead of X++ itself, debugging must be done in a debugger that understands CIL and it almost always means Visual Studio. AX developers sometimes complain about the need of switching between two debuggers, that loading of symbols for debugging is slow and so on. Although these …

Continue reading ‘Tips for CIL debugging: No variables displayed’ »

(In)valid conversion

X++ compiler is very benevolent when dealing with types – much more than it should be. It happily accepts code that can’t succeed at run-time, as I’ll will demonstrate in a minute. It’s unfortunate, because some errors could have been detected at compile-time and they aren’t. And that’s not all – the X++ runtime is …

Continue reading ‘(In)valid conversion’ »