Publising .Net MVC application with Matlab inside to the server

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:29:23

问题


In my ASP.Net mvc 5 application I use MWArray.dll and a matlab function that I generated .dll via Matlab's Library Compiler.

Everything works fine on localhost, but on VDS I rented there is a problem

The exception throwed with the message of "The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception."

Inner exception is

"The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception."

One more Inner Exception is

"Unable to load DLL 'mclmcrrt9_0_1.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

And after I change the dll's with native versions, I get

"Unable to load DLL 'mclmcrrt9_0_1.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

Error.

here is the controller:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MathWorks.MATLAB.NET.Arrays; 
using MathWorks.MATLAB.NET.Utility;
using average; //dll that generated via Matlab Compiler SDK

namespace EleDeneme.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            Random rnd = new Random();
            string[] foo;
            string result = string.Empty;
            try
            {
                using (MWNumericArray matrix1 = new MWNumericArray(new double[20]))
                {
                    for (int i = 1; i <= 20; i++)
                    {
                        if (i % 3 == 0)
                        {
                            matrix1[1, i] = rnd.Next(100);
                            continue;
                        }
                        matrix1[1, i] = rnd.Next(10);
                    }
                    using (average.DenemeClass deneme = new DenemeClass())
                    {
                        using (MWArray res = deneme.average(matrix1))
                        {
                            //for (int i = 0; i < res.NumberOfElements; i++)
                            //{
                            var asdf = res.ToArray();
                            foo = asdf.OfType<object>().Select(o => o.ToString()).ToArray();
                            foreach (var item in foo)
                            {
                                result += item + " ";
                            }
                            Response.Write(result);
                            //}
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
                Response.Write(result);
            }


            return View();
        }


    }
}

the average.dll is a matlab functions compiled version for .net . Also here is the MATLAB code,

function y = average(x)
if ~isvector(x)
    error('Input must be a vector')
end
y = sum(x)/length(x); 
end

before all your answers, I have installed Matlab Compiler Runtime that compatiable with Matlab R2016a to the VDS's C:\Program Files\MATLAB...

I changed IIS applicationpool and my aplications configurations as

IIS 32bit disabled

but still I got the exception same as the exception first time I published to the server.

LocalHost, working Fine (19.9 is my matlab functions output)

来源:https://stackoverflow.com/questions/42568379/publising-net-mvc-application-with-matlab-inside-to-the-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!