Hi all,
I am trying to deploy a MATLAB class that inherits from MATLAB Handle Class to a .NET Framework 4.8 project. Most of the steps I have replicated from this guide using the MATLAB 2024a complier and the MATLAB 2024a Runtime. So far I get a successful compliation on Visual Studio 2022 but upon running I get the following Exception:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Unhandled Exception: System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.Runtime.MATLABRuntime' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libMatlabCppSharedLib24_1': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at MathWorks.MATLAB.Runtime.RuntimeInterop.runtime_create_session(IntPtr[] options, UInt64 size)
at MathWorks.MATLAB.Runtime.RuntimeInterop.InitializeApplication(String[] options) in /mathworks/devel/bat/filer/batfs2557-0/BR2024ad.2537033.BR2024ad.2532478.pass/build/matlab/standalone/dotnet_runtime/src/dotnet_runtime/RuntimeInterop.cs:line 91
at MathWorks.MATLAB.Runtime.MATLABRuntime..cctor() in /mathworks/devel/bat/filer/batfs2557-0/BR2024ad.2537033.BR2024ad.2532478.pass/build/matlab/standalone/dotnet_runtime/src/dotnet_runtime/MATLABRuntime.cs:line 35
--- End of inner exception stack trace ---
at MathWorks.MATLAB.Runtime.MATLABRuntime.StartMATLAB(String ctfFile)
at Test.Program.Main(String[] args) in <redacted>\Program.cs:line 19
Press any key to continue . . .
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It appears to be suggesting that it is unable to locate the 'libMatlabCppSharedLib24_1'. I have checked in <MATLABROOT>/MATLAB Runtime/R2024a/runtime/win64/ and can actually find the libMatlabCppSharedLib24_1.dll in question.
I have referenced the MathWorks.MATLAB.Runtime.dll and MathWorks.MATLAB.Types.dll from the <MATLABROOT>/MATLAB Runtime/R2024a/extern/dotnet/netstandard2.0/ directory. Is there something else I need to make sure I need to configure or double check?
Would appreciate any pointers or improvements to this post.