System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B), Source=MathWorks.MATLAB.Types
Reproduce:
Within a Visual Studio Windows Console app, add references to:
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Engine.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Runtime.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Types.dll
within your static void Main(string[] args) function, add:
MATLABEngine engine = MATLABEngine.StartMATLAB();
This will produce:
System.BadImageFormatException
HResult=0x8007000B
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=MathWorks.MATLAB.Types
StackTrace:
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.array_factory_create_v2(ArrayFactoryHandle& factory)
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.ArrayFactoryCreate()
at MathWorks.MATLAB.Types.Impl.MATLABArrayFactoryImpl..ctor()
at MathWorks.MATLAB.Types.MATLABArrayFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngineFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngine.StartMATLAB()
Any ideas what’s the problem?Reproduce:
Within a Visual Studio Windows Console app, add references to:
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Engine.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Runtime.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Types.dll
within your static void Main(string[] args) function, add:
MATLABEngine engine = MATLABEngine.StartMATLAB();
This will produce:
System.BadImageFormatException
HResult=0x8007000B
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=MathWorks.MATLAB.Types
StackTrace:
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.array_factory_create_v2(ArrayFactoryHandle& factory)
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.ArrayFactoryCreate()
at MathWorks.MATLAB.Types.Impl.MATLABArrayFactoryImpl..ctor()
at MathWorks.MATLAB.Types.MATLABArrayFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngineFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngine.StartMATLAB()
Any ideas what’s the problem? Reproduce:
Within a Visual Studio Windows Console app, add references to:
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Engine.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Runtime.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Types.dll
within your static void Main(string[] args) function, add:
MATLABEngine engine = MATLABEngine.StartMATLAB();
This will produce:
System.BadImageFormatException
HResult=0x8007000B
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=MathWorks.MATLAB.Types
StackTrace:
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.array_factory_create_v2(ArrayFactoryHandle& factory)
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.ArrayFactoryCreate()
at MathWorks.MATLAB.Types.Impl.MATLABArrayFactoryImpl..ctor()
at MathWorks.MATLAB.Types.MATLABArrayFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngineFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngine.StartMATLAB()
Any ideas what’s the problem? matlab, matlab engine api for .net, .net MATLAB Answers — New Questions