Issues with iis 6 and matlab runtime
3 views (last 30 days)
Show older comments
I have very strange problem.
I have programmed some function in matlab and deployed it with Matlab Builder NE as dll file. Next I've added reference to this module into my asp.net application. When I display the web page in browser on localhost (mean visual studio development server), the funtion gives me the numbers I need. However, when I display the web page from remote computer, I get this error :
Exception: System.TypeInitializationException
Message: The type initializer for 'Module.Func' threw an exception.
StackTrace: at Module.Func.Finalize()
InnerException: System.Exception
Message: The MCR instance could not be initialized
I am running IIS 6 and it also throws exception in w3wp.exe. I have no idea, where is the problem, because on localhost it works flawlessly.
Thanks
3 Comments
Leon
on 2 May 2012
Hi,
I had this problem and solved it. The problem occurred in my case happeed after you first installed the MCR on a machine when you run up a first .Net Web App running in IIS that invokes a NE Builder built assembly that invokes a Matlab Script. Thus invoking the MCR.
The problem is related to the Windows security. When your Web App is running in IIS, it is running in IIS_IUSRS account and that have very limited rights to access the file system. For some strange reason I have yet to work out, MCR attempts to insist on accessing some System folders with more rights than needed and attempts to create folders for the MCR version (it does not write anything in it, just needing it to exist).
The error that you'VE received is actually caused by Java Code that threw an exception and you can get this message in the IIS error message log.
The way we got over this is to run ProcessMonitor from http://www.sysinternals.com and watch out for error like "Access Denied" and that gives you pointers to areas where it tried to access the file system with more rights than needed. Once you have determined that area, grant IIS_IUSRS or "Network Service" account access rights to that.
The areas where you need to relax depends on which IIS you use. IIS5 is different from IIS6 and IIS7.
Be patient to scan the log of Process Explorer and the answer is there.
Hope this help and prompt Matlab developers to have a good look at this strange problem. Once relaxed MCR works fine. At the moment, I do not have the precise information with my laptop but it was at work.
Leon
on 2 May 2012
Hi,
There is another possible cause of your problem. Read my blog message for that and the solution:
http://do-the-right-things.blogspot.com.au/2011/06/caveat-in-using-matlab-dll-in-aspnet.html
It is related to the path length when MCR expands your NE Builder built assembly. The way ASP.Net places the temporary files does not help. The end result, if your Matlab NE Builder is several directories down and with long filename, will cause the path name to exceed that permitted by Windows.
My blog provides solution to overcome this problem.
Answers (1)
Wendy Fullam
on 25 Sep 2012
Answered in comments by Leon
Hi,
I had this problem and solved it. The problem occurred in my case happeed after you first installed the MCR on a machine when you run up a first .Net Web App running in IIS that invokes a NE Builder built assembly that invokes a Matlab Script. Thus invoking the MCR.
The problem is related to the Windows security. When your Web App is running in IIS, it is running in IIS_IUSRS account and that have very limited rights to access the file system. For some strange reason I have yet to work out, MCR attempts to insist on accessing some System folders with more rights than needed and attempts to create folders for the MCR version (it does not write anything in it, just needing it to exist).
The error that you'VE received is actually caused by Java Code that threw an exception and you can get this message in the IIS error message log.
The way we got over this is to run ProcessMonitor from http://www.sysinternals.com and watch out for error like "Access Denied" and that gives you pointers to areas where it tried to access the file system with more rights than needed. Once you have determined that area, grant IIS_IUSRS or "Network Service" account access rights to that.
The areas where you need to relax depends on which IIS you use. IIS5 is different from IIS6 and IIS7.
Be patient to scan the log of Process Explorer and the answer is there.
Hope this help and prompt Matlab developers to have a good look at this strange problem. Once relaxed MCR works fine. At the moment, I do not have the precise information with my laptop but it was at work.
0 Comments
See Also
Categories
Find more on COM Component Integration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!