Errors during accessing .dll files using MATLAB

10 views (last 30 days)
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

Accepted Answer

Ayush Singh
Ayush Singh on 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!

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!