I am following an example given on MathWorks documentation page-
to create a .NET assembly. However, when I compile my C# code, it throws the exception:
An unhandled exception of type 'System.TypeInitializationException' occurred in MainApp.exe.
Specifically, the inner exception looks like the following:
{System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception. —> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWArray' threw an exception. —> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at MathWorks.MATLAB.NET.Arrays.MWArray.mclmcrInitialize2(Int32 primaryMode)
at MathWorks.MATLAB.NET.Arrays.MWArray..cctor()
— End of inner exception stack trace —
at MathWorks.MATLAB.NET.Utility.MWMCR..cctor()
— End of inner exception stack trace —
at makesquare.MLTestClass..cctor()}
How can I resolve this?
Best Answer