MATLAB: Does calling a MATLAB .NET assembly compiled after R2017b alter the process Path

MATLAB Compiler SDK

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?

Best Answer

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.