Load dll's from Environment Variable Path from a service
- by Paulo Manuel Santos
We install Matlab Runtime on a machine, then we restart a .net windows service that invokes methods from the Matlab Runtime.
The problem is that we receive TypeInitializationException errors until we restart windows.
We think this happens because Environment Variables are not changed on services until restart and Matlab uses the %Path% variable to reference it's core DLL's.
My question is, do you think I can change the %Path% variable so that Matlab will use it when referencing the core dll's for it's engine?
Or is it possible to add a directory to the runtime DLL loading mechanism of .NET so that those Matlab core dll's would be referenced correctly without restarting the machine?
Here is the exception we get
System.TypeInitializationException: The type initializer for 'MatlabCalculation.Calculation' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'mclmcrrt710.dll': Kan opgegeven module niet vinden. (Exception from HRESULT: 0x8007007E)
at MathWorks.MATLAB.NET.Utility.MWMCR.mclmcrInitialize()
at MathWorks.MATLAB.NET.Utility.MWMCR..cctor()
--- End of inner exception stack trace ---
at MatlabCalculation.Calculation..cctor()
--- End of inner exception stack trace ---
at MatlabCalculation.Calculation.Finalize()
"Kan opgegeven module niet vinden" = "The specified module not found"