Errors during accessing .dll files using MATLAB

6 次查看(过去 30 天)
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

采纳的回答

Ayush Singh
Ayush Singh 2024-2-12
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by