Monday, 18 January 2016

Wrong argument types in variable assignment

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.

JournalId journalId;

Creating a parameter method for this variable.

Public JournalId parmJournalId(JournalId _journalId = journalId)
    journalId = _journalId;

    return journalId;

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.
his 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.

No comments:

Post a Comment