MWArray assembly failed to be initialized

Hi,
I am running and developing this App for long time, I am using a .Net that was compiled with Matlab Library Compiler.
Suddenly today the App stoped working withe the message:
---------------------------
Matlab Error
---------------------------
Error initiating Matlab Library System.Exception: MWArray assembly failed to be initialized ---> System.Exception: The MATLAB Runtime instance could not be initialized ---> System.ApplicationException: The MATLAB Runtime instance could not be initialized
segv - SEVERE ERROR
at MathWorks.MATLAB.NET.Utility.MWMCR..ctor(String componentId, String componentPath, Stream embeddedCtfStream, Boolean isLibrary)
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Utility.MWMCR..ctor(String componentId, String componentPath, Stream embeddedCtfStream, Boolean isLibrary)
I tried to recompile, reinstall the real time engine install previous version and still getting this message.
I am not sure what changed. I installed the App in a different computer and no problem at all.
Your help will be greatly appropriated.
Thanks
Sharon

 Accepted Answer

Your MATLAB Runtime cache folder might be corrupted.
Delete the cache folder.
%TEMP%\USER\mcrCacheX.X
If your Windows account is usera and MATLAB Runtime version is 9.3 (R2017b),
the above folder would be
C:\Users\usera\AppData\Local\Temp\usera\mcrCache9.3
After deleting this folder, you can freshly launch your compiled application.

12 Comments

Thanks for your answer. I ended up reinstalling the Run Time engine again in a different directory which solved the problem. I do have Matlab 2017b running on this computer, I though I will not need the Run Time to be installed when Matlab is installed, can you please clarify?
If you have MATLAB, you don't need to install the corresponding MATLAB Runtime in that machine. You can run the compiled application with MATLAB's runtime. You can run the application under for_redistribution_files_only folder of your compiling output. For detail, please see this answer.
Thanks for the info.
I was trying to run without the runtime engine since I have matlab instaled on this computer, but still got the message as before.
After removing the cach directory it starts working again.
Not sure what causes thos issues, never had them before.
Thanks
Sharon
Hi,
Something is very wrong, every time I need to invoke an application that uses the run time engine I need to remove the directory you mentioned, not sure what change but it is very hard to work this way.
Thanks
Sharon
I was hoping by now someone from Mathwork will replay to this, it is very problematic issue. It is imposible to use this tool for a software that we are developing for customers.
Were you able to find a solution to this? I'm running into this as well. Every time I run my app, I have to delete the cache.
No, nobody from Mathworks reacted to this, I know how annoying it is to remove the cache all the time. I am not sure this is a software I can ship to cusomers when this issue pops up all the time.
Hi Sharon,
I have had similar issues with the MCR cache. I believe they were caused because the default location of the MCR cache is under the Windows Temp folder as mentioned by Kojiro above. This can cause problems due to windows continually tryinf to "clean up" the temp folder and in doing so corrupting the cache. Deleting it entirely works temporarily as the MCR then knows it needs to recreate the cache folder, as you have seen
Our workaround was to move the location of the MCR cache folder by setting the MCR_CACHE_ROOT environment variable. A relevant Mathworks forum post can be found here:
This solution totally worked to me, thanks!
This worked for me too! Thank you.
Issue occured on Matlab Runtime 9.8 as well. But these steps resolved it. Thanks!
Thank you very much, I was going crazy looking for issues elsewhere and this worked like a charm!

Sign in to comment.

More Answers (0)

Products

Release

R2017b

Community Treasure Hunt

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

Start Hunting!