- 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
11 次查看(过去 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.
更多回答(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!