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 views (last 30 days)
Show older comments
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.
Accepted Answer
MathWorks Support Team
on 28 Jun 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.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!