I have strange issue when I call matlab function from C# class. The most of time is everything ok but sometimes (1 call from 100 calls, maybe 1000 or one call in day for example - I can measure it in future) i get a strange MWMCR error. Of course the error cause the exception in my C# code. The behavior is same on two computers.
The message from the exception always seems as follows
... MWMCR::EvaluateFunction error ...
The file
"C:\Users\user\AppData\Local\Temp\VF\mcrCache9.2\Matlab1\Program Files\MATLAB\R2012b\work\frm\file_with_called_function.m"
cannot be executed..
The details from the exception is
Failed to open file 'C:\Users\user\AppData\Local\Temp\VF\mcrCache9.2\Matlab1\Program Files\MATLAB\R2012b\work\frm\file_with_called_function.m'. Details: 'File stream is closed. The following flags are set: failbit.'
And mscorelib error
mscorlib::Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
(Of course I have the whole call stack but it does not seem very useful.)
As you can see I use MWMCR v 9.2. (MATLAB 9.2, release R2017a) and MWMCR works in user's temp directory. Interesting is when I explore the directory after error the directory is empty. I do not know that is normal behavior.
And the question. Why MWMCR sometimes can not open the file (evaluate the function)?? The related question is why is (in my case) failbit on the stream setted and why is filestream closed??
And subquestions. How MWMCR works with user's tmp folder? MWMCR copy the matlab file to the temp directory, works with them and delete them?? Why is directory empty??
Thank You.