Why does calling a MATLAB .NET assembly compiled after R2017b alter the process Path?

1 view (last 30 days)
I've compiled a simple .NET assembly using the MATLAB Compiler SDK Library Compiler. I've also written a .NET application in Visual Studio, which calls this assembly.
In the app I add some entries to the Process Path using the "Environment.SetEnvironmentVariable" method, then I call into the MATLAB .NET assembly.
When I compile the MATLAB .NET assembly in R2017b or earlier, everything works as expected. However, if I compile the assembly in a release later than R2017b all entries that I add to the process Path before calling into the compiled assembly are removed upon instantiation of the compiled assembly. It appears that during this function evaluation, the process Path is replaced with a copy of the machine Path.
Is this expected? Why has this behavior changed between releases?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Jun 2020
This behavior is likely the result of a change in the foundation libraries of MATLAB runtime. This behavior ensures that MATLAB library paths are in the front of the search path to avoid third-party library conflicts.
The recommended workaround is to modify the Process Path after the instantiation of the compiled assembly. Doing this, you should still be able to change the Path in the process level without affecting MATLAB runtime.

More Answers (0)

Categories

Find more on MATLAB Compiler SDK in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!