April 4, 2009 at 12:46
filed under Dynamics AX
Tagged Dynamics AX, Inheritance
While doing some modifications to the class SalesFormLetter, I ran into something very strange. I did two simple things:
Adding an object member variable to the class declaration.
Creating a parameter method for this variable.
On compilation, this didn’t show any errors, but when the code was executed, the debugger popped up, and the following error was thrown upon assignment:
Wrong argument types in variable assignment
I recompiled it, ran it again, same error. A colleague took a look at my code and couldn’t find anything wrong with it either, and suggested to stop the AOS and rebuild the .aoi file, but that didn’t do it either.
When I debugged I noticed the the object member journalId didn’t sow up in the list of members in the debugger. A moment after that my colleague asked if I had tried compile forward yet, and I immediately knew that would solve the problem. It did.
MSDN states on several occasions:
It is important to compile forward from the parent class when adding a variable to a classDeclaration of a class that is inherited by other classes.
This was the case with the SalesFormLetter modifications I did.
So always remember to use compile forward when modifying super classes, and it will save you a lot of trouble.
KrMee
on April 6, 2009 at 16:25
Legend: “A colleague”, also known as KrMee :-)
Brett
on March 19, 2010 at 04:58
Thanks for your blog post. I was banging my head against a wall for at least half an hour, unable to figure out why a string input couldn’t be assigned to a string variable…. – the compile forward tip worked a treat!