• .net 调用 Matlab生成dll出现的问题(The type initializer for 'MathWorks​.MATLAB.NE​T.Utility.​MWMCR' threw an exception.)


    https://cn.mathworks.com/matlabcentral/answers/278399-i-get-an-error-saying-the-type-initializer-for-mathworks-matlab-net-utility-mwmcr-threw-an-except

    这篇文章帮忙解决了问题

    记录一下备忘:

    Hi Nug,

    Ensure that you have the MCR version corresponding to MATLAB 2012b installed. You can check that from the following link.

    MATLAB Runtime

    After ensuring that you have the correct version of MCR, it will be useful to check the system path. If you have either MATLAB or any other version of MCR installed on your machine, please make sure that the one you are running the deployable against appears higher in the system path than any other MATLAB/MCR runtime.

    To view or change environment variables:

    1. Right-click My Computer, and then click Properties.
    2. Click the Advanced tab.
    3. Click Environment variables.
    4. In the 'System Variables' search for the variable named 'Path' and ensure that the MCR installation for R2012b appears higher than in the path than any other MATLAB/MCR runtime

    Also, are you using the Web installed MCR or the packaged MCR?

    There might be two possible causes for the error to appear:

    A) This error can appear if you copied the MATLAB Runtime DLL mclmcrrt8_0.dll to the folder that contains your .NET application or to some other Windows system folder. If you copy this MATLAB DLL to another folder, when it tries to find its further dependencies it will fail.

    To work around this issue, remove any unnecessary copies of the file and leave the file in the installation folder belonging to MATLAB or the MCR.

    B) The issue might be due to the fact that the packaged MCR installation is not adding the MWArray properly to the machine Global Assembly Cache (GAC). So in such a case, the deployed component picks up the older MWArray already installed in the GAC and fails. The GAC preempts other references so even if you specifically reference the R2015a MWArray by browsing to it and referencing it in Visual Studio, it may not work.

    In order to workaround this issue you would need to either:

    1. Uninstall the other MWArrays from the GAC (so you make sure it picks up the referenced MWArray)
    2. Add the R2012b MWArray into the GAC using Microsoft's gacutil.exe. More information about this can be seen from the link below :

    http://msdn.microsoft.com/en-us/library/dkkx7f79(v=vs.110).aspx

    I hope either of the above workarounds helps you to resolve this issue.

    -Rohit

     
  • 相关阅读:
    mixin混合
    python类内部调用自己的成员函数必须加self
    合并/取消合并单元格
    pandas 显示所有的行和列
    pandas 利用openpyxl设置表格样式
    Nowcoder9983G.糖果(并查集)
    Nowcoder9983F.匹配串(思维)
    Nowcoder9983E.买礼物(链表+线段树)
    Nowcoder9983C.重力追击(暴力+少用sqrt)
    Nowcoder9983B.内卷(双指针)
  • 原文地址:https://www.cnblogs.com/Cavalry/p/6424813.html
Copyright © 2020-2023  润新知