System.TypeInitializationException in Visual Studio 2013 when run .dll files which compile by old Matlab version.
10 views (last 30 days)
Show older comments
I have a old application build by C# and they use some .dll files (m2m_aoa.dll, m2m_ctoa.dll, MWArray) which built by Matlab. I assume it was build by 32bit system. They all reference path at " project_name\bin\Debug\". Now I run that application in new system with Matlab 2014a (64bit),Visual Studio 2013 and MCR_R2014a_win64_installer.
1. First time, from Visual Studio, I run it in x86 platform, I got problem in line of code
"MWNumericArray mwMS = new MWNumericArray(MWArrayComplexity.Real, 2, 1); "
with error:
Exception:Thrown: "The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception." (System.TypeInitializationException) A System.TypeInitializationException was thrown: "The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception."
and they stuck in that line of code.
2. I try to build in x64 platform with copy MWArray.dll from "dotnetbuilder\bin\win64\v2.0" into directory :
bin\Debug\MWArray.dll
I run again and they pass that line of code. But I got new error in another m2m_ctoa.dll file which use MWArray (this file also is built by Matlab) in this line of code:
ctoa = new CTOA();
with two errors
Exception:Thrown: "Could not load file or assembly 'MWArray, Version=2.9.1.0, Culture=neutral, PublicKeyToken=e1d84a0da19db86f' or one of its dependencies. An attempt was made to load a program with an incorrect format." (System.BadImageFormatException) A System.BadImageFormatException was thrown: "Could not load file or assembly 'MWArray, Version=2.9.1.0, Culture=neutral, PublicKeyToken=e1d84a0da19db86f' or one of its dependencies. An attempt was made to load a program with an incorrect format."
and
Exception:Thrown: "The type initializer for 'm2m_ctoa.CTOA' threw an exception." (System.TypeInitializationException) A System.TypeInitializationException was thrown: "The type initializer for 'm2m_ctoa.CTOA' threw an exception."
Then the application shutdown immediately if I do not try catch in this line of code.
I am so confuse.
All errors happen with these .dll files. I feel VS can not read these files. Maybe they are empty but their space up to 88KB each.
Could these old .dll files which build from 32bit platform able run in my system? If it could, how can I fix it?
Are the location of these files normal? they are in directory " project_name\bin\Debug\" and the reference paths are match.
Do I have to compile these files from Matlab again? In this case, could I convert dll file to Matlab code?
Please help me. Thank you very much in advance.
0 Comments
Answers (0)
See Also
Categories
Find more on Deploy to C++ Applications Using mwArray API (C++03) in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!