Why do I receive a runtime error when running an application that uses .NET 4.0 framework created with MATLAB Compiler 4.14 (R2010b)?

5 visualizzazioni (ultimi 30 giorni)
I have a code that calls a .NET 4.0 DLL using NET.AddAssembly. This code works fine inside MATLAB. I am using MATLAB Compiler 4.14 to build a console application from the aforementioned code. I receive the following error at runtime
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 28 Giu 2013
This issue occurs when the compiled executable tries to load the assembly with .NET 2.0 framework by default. In order to overcome this issue, create a CONFIG file. For example, if your executable is 'foo.exe', create a file called 'foo.exe.config'. Add the following contents to that file
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
This will make sure .NET 4.0 is available when the application is running. The CONFIG file should be located in the same directory as the executable.

Più risposte (0)

Categorie

Scopri di più su MATLAB Compiler in Help Center e File Exchange

Prodotti


Release

R2010a

Community Treasure Hunt

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

Start Hunting!

Translated by