whisps11
whisps11

Reputation: 75

matlab code on IIS not working

I am using VS2013, Matlab 2015Ra, and IIS 10. Net framework is 4.5.2 and EF is 6. Matlab 2015Ra, VS2013, and IIS are 64 bit on windows 10 which is also 64 bit. I have MatLab script compiled as net assembly. When I use development server, the program works fine without error, while when it is deployed on IIS program fails to execute MatLab code with this exception message:

The MATLAB runtime instance could not be initialized segv - SEVERE ERROR

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ApplicationException: The MATLAB runtime instance could not be initialized segv - SEVERE ERROR

The complete stack trace is:

    [ApplicationException: The MATLAB runtime instance could not be initialized
    segv - SEVERE ERROR] MathWorks.MATLAB.NET.Utility.MWMCR..ctor(String componentId, String componentPath, Stream embeddedCtfStream, Boolean isLibrary) +282

    [Exception: The MATLAB runtime instance could not be initialized]
    MathWorks.MATLAB.NET.Utility.MWMCR..ctor(String componentId, String componentPath, Stream embeddedCtfStream, Boolean isLibrary) +736
    BuildCrop.Cropper..cctor() +390

    [Exception: MWArray assembly failed to be initialized]
    BuildCrop.Cropper..ctor() +43
    EMS.Controllers.AdministratorController.Test_CreateCrop() +186
    lambda_method(Closure , ControllerBase , Object[] ) +87
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext 
    controllerContext, IDictionary`2 parameters) +229

 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
  System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
  System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +67  
  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod (IAsyncResult asyncResult)+42
  System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +72
  System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386   
  System.Web.Mvc.Async.AsyncControllerActionInvoker. EndInvokeActionMethodWithFilters  (IAsyncResult  asyncResult) +42
  System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +38
  System.Web.Mvc.Async.<>c__DisplayClass21.
  <BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186
  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction (IAsyncResult asyncResult) +38
  System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
  System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
  System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
  System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44
 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38   
 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication. IExecutionStep.Execute() +399
 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +157

I have looked at various solutions and articles, also tried solutions suggested by Leon on https://www.mathworks.com/matlabcentral/answers/29604-issues-with-iis-6-and-matlab-runtime and L. Mar in http://do-the-right-things.blogspot.com.au/2011/06/caveat-in-using-matlab-dll-in-aspnet.html

I also increased the server.scripttimeout in IIS but the same error message appears.

PS: Matlab is installed on server and dlls are created from same Matlab.

Upvotes: 1

Views: 1191

Answers (1)

whisps11
whisps11

Reputation: 75

Update

So in case someone might got into same situation, I will explain how I resolved it so that it might save some time. This error is particularly related to mcrcachex.x (in my case mcrcache8.5 as I am using Matlab 2015a). When moving this folder from C:\Users\\AppData\Local\Temp\\ do not delete its contents as ".mcr_cache_index" has importance in it somehow. Before deleting, copy this file ".mcr_cache_index" somewhere safe and after creating MCR_CACHE_ROOT in environement variable and providing path to c:\mcrcahex.x, paste the ".mcr_cache_index" file that you saved for later use into this folder on c:\mcrcahex.x path. Later you can delete the mcrcachex.x from previous paths so that mcr wont look in these folders again on execution. Also provide access right permissions to it so compiler can create files in it.

Upvotes: 1

Related Questions