Filter löschen
Filter löschen

load x86 .NET assembly in Matlab

18 Ansichten (letzte 30 Tage)
Pavel
Pavel am 10 Aug. 2022
Beantwortet: Dinesh am 23 Okt. 2023
Hello I have a slightly unusual problem.
I have an external .NET assembly which is only available as x86 BUT is built targeting NET 6.0, I need to load it into matlab model of which I have 2 versions one for 2018b and one for 2010b
If I try to load it into R2018b I get an error "An attempt was made to load a program with an incorrect format" - which I assume is because I am trying to load x86 assembly into x64 version of Matlab?
If I try to load it into R2010b (32-bit version) I get an error "Unable to load one or more of the requested types" and if I then drill down to exception I get the message "could not load file or assembly 'system.runtime, version=6.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' or one of its dependencies. the system cannot find the file specified" - is it because MATLAB2010b is too old to recognize NET6.0?
If I build my own little app in VS2022 and try to call methods from the assembly everything works fine.
Your help would be appreciated, and any pointer on what I can do in this situation?
Many tnanks
  1 Kommentar
Walter Roberson
Walter Roberson am 10 Aug. 2022
Support for NET 6 is quite recent, only the last release or two.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Dinesh
Dinesh am 23 Okt. 2023
Hi Pavel!
I understand that you are trying to load a .NET x86 assembly that is built targeting .NET 6.0. However, you are encountering the error "attempt was made to load a program with incorrect formula" in MATLAB R2018b. There are two main reasons for this issue:
  1. Main reason :- x86 assembly cannot be loaded in x64 host process unless the target is Any CPU / ANY CPU prefer 32bit.
  2. MATLAB R2018b does not support .NET 6.0. MATLAB R2018b supoprts .NET 4, 4.5, 4.6 only.
Please refer to the following MATLAB supported compilers for MATLAB R2018b
The support for .NET version 6.0 started from MATLAB R2022b. Hence, you would need MATLAB R2022b to load the .NET assembly that is built targeting .NET 6.0. Prior to that, MATLAB R2015b was the last version that had a 32-bit installation.
If you want to load the assembly in MATLAB versions greater than R2016a, consider changing to an x64 assembly. If you wish to work with .NET 6.0, you will need to update your MATLAB to R2022b or a later version.

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by