The everyday life of a Dynamics AX developer
When creating and using services you can get the following error:
No metadata class defined for data contract object
When you get this error it means that you are trying to use a type as a data contract that is not a valid data contract type.
Valid type are primitive types, tables and views, data contracts, containers, EDT’s, and collections (For a full list of supported types, check the Using Data Contracts in X++ [AX 2012] page on msdn.
To figure out what data member is causing a problem, put a breakpoint at the throw error in the SysOperationDataContractInfo.newParameterInfo() method. When the breakpoint is hit, the data member will be displayed in the _parentMethodParameterName variable and the type in the dictClass variable.
To solve the problem, use a type that is supported. If you want to pass a class, either pass it as a container (e.g. using a pack() method), or better yet, define the class as a data contract with data members.
Note: I’ve also seen this error pop up when the data contract wasn’t correctly compiled. Simply put a breakpoint as described above to figure out what data contract is causing the problem and compile the class (both X++ and CIL). Keep in mind that you might have to compile forward if the class is extended, or do a compile forward on the class that it extends.