Is it possible to recover a corrupted *.mlapp file?

I was working on an app and had just got the thing to work when the file became corrupted. When I tried to run the file (and now when I try to open it), I get an error dialog:
"Error loading 'PlotDigitizer.mlapp'.
And then this appears in the command window:
"Error using which
C:\Work\Matlab\Apps\Plot Digitizer\PlotDigitizer.mlapp: Can't open file.
Error in run (line 55)
pathscript = evalin('caller', strcat('which(''', script, ''')'));"
I tried to find a solution to this online and came up with reseting preferences... which didn't work.
This the second time this has occured, forcing me to loose several hours of work, and I am not even sure what I did to cause it, if anything. It seemingly worked one minute and then not the next.
Is App Designer that unstable? Is there a way to recover this or at least copy the text portion of the code?
Also, what options do I have for backup or autosave?

2 Comments

If you restart Matlab, is the result any different?
Negative. Reseting the preferences required a restart of Matlab.
I attached the *.mlapp file to the original post if you want to give it a shot.

Sign in to comment.

 Accepted Answer

The app became corrupt due to an invalid character entered on line 413:
if(c == <escape character here>) % Exit when Esc key is pressed
The "escape" character that you used is not supported in the MLAPP code file. This is a bug and I have reported it to the App Designer team.
I fixed the app (attached) so that it will now load by removing the escape character and replacing it with 'escape'. A better way to detect if the user has pressed the escape key is to add a KeyPressFcn to your app's UIFigure and use the event.Key in the callback to determine if escape was pressed:
function UIFigureKeyPress(app, event)
key = event.Key;
% Check if key == 'escape'
end

8 Comments

Thank you very much for the fix and advice!
can you tell me how to fix files like this?
i too have faced similar issue just now, unfortunately i dont have any backup of the working version of the mlapp file, can you fix my file also?? pls let me know, i will be very grateful for the help. Also, how to rectify such issues in future?
@Sai Sandeep Chigurupati - your issue is different. Your attached mlapp file is not even being recognized as an app as it contains just null bytes. Unfortunately, it is not recoverable. Can you describe what you were doing when this happened? Did you lose power as you were saving the app or was the app saved on a network drive?
I was debugging with breakpoint and stepping through each line of code. When it reached one line where it is supposed to pop up an error dialog indicating an error for the user input, somehow it went into kind of infinte loop or something, it kept on popping up the error dialog continuously, then i stopped the execution and the popping up stopped, i was closing all the pop up windows one after the other, then suddenly there was blue screen which comes when windows crashes , it mentioned some error code which could not be noted down as the system quickly restarted.
Thats all. after the system restart, when i tried opening the file, it was showing cannot open file.
If theres any way to recover this file, it would be a great help as it had progress of two weeks of efforts.
Thanks
It shows the following error message in MATLAB command window:
Error using which
C:\Users\HP\Documents\MATLAB\DFT_client.mlapp: Can't open file.
Error in run (line 55)
pathscript = evalin('caller', strcat('which(''', script, ''')'));
@Sai Sandeep Chigurupati that zip file seems invalid as well and not recongized as a zip file. I would recommend that you contact customer support (https://www.mathworks.com/support/contact_us.html).

Sign in to comment.

More Answers (1)

If the .mlapp is corrupted you can still recover user-defined code and other things by opening the .mlapp as an archive using 7-zip.

Categories

Products

Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!