MATLAB Answers

MWArray assembly failed to be initialized in C#

60 views (last 30 days)
I have developed a project of"Automatic Number Plate Reader" in matlab and I want to call this project in C# windows application for further process.But when i implement this in C# i got a error as "MWArray assembly failed to be initialized". Wherein I have generated all the dll files in matlab and added it in the reference of the C# project from the deploytool in matlab. And MWArray.dll is also been added. I am using 2013a version of matlab and 2012 version of Visual Studio. Any help regarding this is quite helpful.
  1 Comment
Wenchao Tao
Wenchao Tao on 3 May 2018
Hi, I'm wondering if you have found the solution to the error of "Error initializing CTF Archive". I have this error randomly when use compile dll in a C# application. Tried to clean the MCR temp folder, reset the MCR temp folder location and still not able to fix this random error.

Sign in to comment.

Accepted Answer

Matthew Monreal
Matthew Monreal on 18 May 2015
I came across your problem when I was trying to solve my own. Now I got back to you since I've managed to solve it.
First of all it appears that the MWMCR is only compatible up to .net framework 3.5.
Second make sure that you are generating the *.ctf file when building your function in MATLAB. you need to untick the option where it says that the .ctf is embedded in the application. Its in the settings of the deploytool itself.
Third when after you create the fill debug the program until you reach the code part in the static constructor of your classwhere it finds the assembly location and take note of the folder location.
string ctfFilePath= assembly.Location;
You would need to manually copy and paste the *.ctf file to that location and it should work.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!