web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Error* "The model element was saved with unparsable source code and cannot be used".

(0) ShareShare
ReportReport
Posted on by

An  event handler class is created for a form extension to handle some new added form controls , when I build the project I face the below 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)  in event handler class xpp file , how can I fix this issue ?

*This post is locked for comments

I have the same question (0)
  • Jonathancm Profile Picture
    416 on at

    Hi, are you sure you don´t have any other issue in the error log?

    I've seen that message when there's also something else in the source code.

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    Actually this error can only be resolved if you remove and add the erroneous code again. At least that is how I had to deal with it in a class of mine.

    I copied multiple methods in a class all at once and this error showed up.

    So I copied and saved the code somewhere else, removed all code and then added the methods one bye one again (compiled/built after every method's addition). Only one method was causing this error.

    Try the same, you'll find the error containing part of the code and then you can fix it.

  • maram fraij Profile Picture
    on at

    it is a strange behavior in VS  I just cut code some piece  of code in the event  handler class  , paste it again then build the project , the error disappears. Actually, I do not have any error  in the code.

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    Well it is not strange, when you were writing the code it might have been saved in the middle and with errors and when you completed it, the saved code wasn't updated in the already built solution. When you removed and added the code again, it rebuild the solution and the code is error free now.

    Its always a good practice to build/compile your work after every change you make.

    If your issue has been resolved please mark the helpful replies as verified and close this thread.

  • maram fraij Profile Picture
    on at

    Just to make sure that I understand the fixing of this issue ,  If I rebuild the whole project instead of build and without making any vague  changes in the the code to be saved, this will resolve the issue? 

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    There is no need to rebuild the whole project every single time you make a small change, just keep building while you're making changes and make sure there are no errors, then when you are done making changes. Rebuild your project to sort out any inconsistencies if any.

  • maram fraij Profile Picture
    on at

    I've just tried to rebuild  without making   vague  changes but it does not work

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    Did you remove and added the class you are working on?

    Save the code, delete the class completely, rebuild your project.

    After that create the class again, add the code then rebuild. Try doing that.

  • maram fraij Profile Picture
    on at

    I just try to find the resolution for such error if I face it another time since making vague changes is not reasonable resolution , also removing the class and adding it again is not the best resolution?  

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    Well maram maybe someone else has another idea but this is the best to my knowledge for this right now,

    I faced this issue only once and that is how I had to resolve it, after that I build my work after every small change I make. Has not happened to me again.

    I would think that If you keep building your solution along the way properly you shouldn't see it again.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans