Standalone application cannot read p-code?

2 Ansichten (letzte 30 Tage)
Pelajar UM
Pelajar UM am 17 Sep. 2021
Beantwortet: Steven Lord am 17 Sep. 2021
So my app has an input library that is not bundled together with the app itself. I want to be able to share only specific inputs with other users. These input files are in the customized .x format (this is just a name, in reality they are merely p-code). This is done so that the end user cannot change the values.
This code converts the .x file back to .p and then reads it.
function LoadDataButtonPushed(app, event)
[filename, folder] = uigetfile ({'*x'});
if ~ischar(filename); return; end %user cancel
filename = fullfile(folder, filename);
tf = tempname + ".p";
copyfile(filename, tf);
cleanMe = onCleanup(@() delete(tf));
run(tf);
clear cleanME %delete file
%run (filename);
end
Everything works within matlab but when I run the standalone app, I get this error:
Error using run (line 68)
RUN cannot execute the file 'C:\User\AppData\Local\Temp\tp5c2adeb2_27cb_4c29_a65b_a473ebe3e346.p'. RUN requires a valid MATLAB script
Error in A2P2/LoadDataButtonPushed (line 497)
Error in appdesigner.internal.service.AppManagementService/tryCallback (line 369)
Error in matlab.apps.AppBase>@(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (line 37)
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 410)
Error while evaluating Button PrivateButtonPushedFcn.

Akzeptierte Antwort

Steven Lord
Steven Lord am 17 Sep. 2021
Standalone apps cannot run any MATLAB code that was not included in the application at compile-time. From the documentation "MATLAB Runtime only works on MATLAB code that was encrypted when the deployable archive was built. Any function or process that dynamically generates new MATLAB code will not work against MATLAB Runtime."
Your .p files were not included as program files at compile-time, they were included as data files and so cannot be executed at run-time.
For using data files in a standalone application, see this documentation page.

Weitere Antworten (0)

Kategorien

Mehr zu App Building finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by