June 08, 2018

Solution: Build error for new class in D365FO

Error: The model element was saved with unparsable source code and cannot be used. Please edit the element in Visual Studio to fix the errors: <ProjectName> (CUS) [<Modelname>] K:\AosService\PackagesLocalDirectory\bin\XppSource\<ModelName>\<ObjectName>.xpp



Possible reason: Sometimes when we rename the object name in code and manually rename the object from Solution Explorer, respective metadata still pointing to old names. Ideally, it should be another way around, rename the object in solution explorer and then just open the object it will automatically rename in class code.

Suggested Solution:
This issue doesn't fix even after DB synch and Model build. The only solution I can find for this issue is by deleting the object and create a new one. Yes, delete the object and create a new one with same code and name. This should fix this error.
Let me know if you found some other fix for the same.

Cheers
-Harry