Errors during accessing .dll files using MATLAB

6 Ansichten (letzte 30 Tage)
Sushant
Sushant am 8 Feb. 2024
Beantwortet: Ayush Singh am 12 Feb. 2024
Hello all,
Currently i am planning to run a .dll file from an SDK using my MATLAB App vreated in App Designer, and I am facing a few errors with the same. (error shown below)
I would greatly appreciate if anyone can help me with these issues.
Best,
Sushant
Error loading DLL: Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
Error in App_Sushant_2/startupFcn (line 124)
app.statusText.Text = errorMessage;
The code refreed to in the error message shows assigning a public property as app.dllHandle and has it code as follows:
  • methods (Access = public)
% Construct app
function app = App_Sushant_2
app.dllHandle = [];
  • try
% Load the DLL and store the handle in dllHandle property
app.dllHandle = loadlibrary(dllPath, headerFile); %'alias', 'Neurostimulator_HID_DLL_2'
app.statusText.Text = 'DLL loaded successfully';
catch ex
% Display error message if DLL loading fails
errorMessage = sprintf('Error loading DLL: %s', ex.message);
disp(errorMessage);
app.statusText.Text = errorMessage;
return;
end

Akzeptierte Antwort

Ayush Singh
Ayush Singh am 12 Feb. 2024
Hi Sushant
In order to get rid of the error you may try the following :
  1. The 'dllPath' and 'headerFile' should be correctly defined in the code in order to use them correctly.
  2. This assumes that 'app.statusText' is a valid UI property. If 'app.statusText' does not exist or is not correct type of UI control this line will throw an error.
  3. Lastly try changing the line 'app.statusText.Text = errorMessage;' to app.statusText.Text = ex.message' and then try to run the code.
I hope the above information helps!

Weitere Antworten (0)

Kategorien

Mehr zu Downloads finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by