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 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
MathWorks Support Team
2013-6-28
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!