MATLAB: Does MCR cache(CTF extraction path) get corrupted after running the executable for several number of times using MATLAB Builder NE 3.1 (R2010a)

corruptedMATLAB Builder NEmcr

We have a .NET application where functions of a MATLAB Builder NE generated DLL are called.
It happens that the mcrCache gets corrupt, such that executing the DLL function always results in an error:
Undefined function or method 'iptcheckinput' for input arguments of type 'cell'.
Error in =>PC_initWorkspace.m at 20.
... Matlab M-code Stack Trace ...
at
file C:\Temp\jennis\mcrCache7.13\People0\toolbox\images\images\watershed.m,name parse_inputs,line at 193.
at
file C:\Temp\jennis\mcrCache7.13\People0\toolbox\images\images\watershed.m,name watershed,line at 139.
at
file C:\Temp\jennis\mcrCache7.13\People0\LocalData\SVN\10_PeopleCounting\Matlab\MainFunctions\PC_initWorkspace.m,name PC_initWorkspace,line at 20.
This happens only after running the application for several number of times. The number of files also reduce eventually. When I manually delete the entire mcrCache\AppName directory helps resolving the issue. I am wondering what could be the reason for corrupted CTF extraction.

Best Answer

It may not be MATLAB which causes an issue here. The problem is that the mcrCache is by default somewhere below your TEMP directory. Certain system/network tools/services might try to "clean" TEMP directory. Possible solutions for this issue would be:
1. Use MCR_CACHE_ROOT environment variable to redirect the cache to a location not below TEMP
2. Do not embed the CTF. You can choose not to embed CTF in the deploytool by going to settings and there is an option "Embed CTF", that will be checked by default. You can uncheck that option to not embed CTF with the component created. The not-embedded CTF will then not be extracted to the mcr_cache but rather to a directory below the directory containing the CTF.