- Compile the .NET assembly with 64-bit MATLAB Builder NE for 64-bit dependencies.
- Configure the server to run both 64-bit and 32-bit processes, ensuring 32-bit applications use a 32-bit process.
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B), Source=MathWorks.MATLAB.Types
조회 수: 13 (최근 30일)
이전 댓글 표시
Reproduce:
Within a Visual Studio Windows Console app, add references to:
C:\Program Files\MATLAB\R2024b\extern\dotnet\netstandard2.0\MathWorks.MATLAB.Engine.dll
C:\Program Files\MATLAB\R2024b\extern\dotnet\netstandard2.0\MathWorks.MATLAB.Runtime.dll
C:\Program Files\MATLAB\R2024b\extern\dotnet\netstandard2.0\MathWorks.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?
댓글 수: 0
채택된 답변
Animesh
2024년 10월 6일
NET assemblies from MATLAB Builder NE are compiled into architecture-independent MSIL but have platform-dependent dependencies like DLLs or MEX-files. Thus, assemblies from 32-bit MATLAB can only be referenced in x86 projects. On a 64-bit server, a 32-bit web application is typically launched by a 64-bit process, but requires a 32-bit process due to its dependencies. Here are a few things you can try to resolve the exception:
You can refer to the following thread; it discusses a similar issue.
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 COM Component Integration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!