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

 

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

  1. Matlab生成.dll文件在.NET中加载失败与平台的关系及解决方案

    问题链接地址:http://bbs.elecfans.com/forum.php?mod=viewthread&tid=207995

  2. asp.net下调用Matlab生成动态链接库

    对于这次论文项目,最后在写一篇关于工程的博客,那就是在asp.net下调用matlab生成的dll动态链接库.至今关于matlab,c/c++(opencv),c#(asp.net)我总共写了4篇配置 ...

  3. WPF调用C++生成的dll文件(示例)

    注:笔者使用的VS版本为2019.1.打开VS2019,选择文件 -> 新建 -> 项目 2.选择项目 新建项目时选择C++“控制台应用”语言:C++平台:Windows项目类型:空项目 ...

  4. c++调用matlab生成的Dll动态连接库

    点击打开链接http://download.csdn.net/detail/nuptboyzhb/4228429 c++调用matlab生成的Dll动态连接库 实验平台:   matlab 7.0(R ...

  5. C#调用Matlab生成的dll方法

    其实整个过程比较简单,但是需要心细一点. 需要的工具:VS2005及以上版本,MATLAB2008B及以上版本,另外非常重要的需要安装一个MATLAB Compiler Runtime,这个文件(MC ...

  6. C#调用Matlab生成的Dll

    问题描述:最近开发需要调用matlab生成的DLL,在New MWNumericArray 对象的时候报错,提示未将对象引用到对象的实例. 问题分析:因为MWArray.dll是Matlab提供的DL ...

  7. c++与matlab联合编程,调用Deploytool 生成exe文件和dll文件(转)

    转自:http://www.cnblogs.com/xlw1219/archive/2012/12/25/2832222.html 首先必须知道联合编程需要知道的一些命令解释: mcc 的作用是将 . ...

  8. MATLAB中.m文件生成.dll

    1.配置编译环境 在命令行窗口输入: mbuild -setup 如果出现以下提示信息说明成功: 如果提示信息为: 错误使用mbuild(line 164) Unable to complete su ...

  9. C# 调用WebService的3种方式 :直接调用、根据wsdl生成webservice的.cs文件及生成dll调用、动态调用

    1.直接调用 已知webservice路径,则可以直接 添加服务引用--高级--添加web引用 直接输入webservice URL.这个比较常见也很简单 即有完整的webservice文件目录如下图 ...

随机推荐

  1. react源码探索

    react核心部分为 虚拟dom对象 虚拟dom差异化算法 单向数据流渲染 组件生命周期 事件处理 1) 虚拟dom对象: reactDOM.render(args,element); 这个方法第一个 ...

  2. html 入门 "地表最强"干货 你值得拥有

    # 入门 ## 一.前端三剑客 #### html ```完成页面架构的搭建文件: .html``` #### css ```完成页面样式布局(装修)文件: .css``` #### js ```完成 ...

  3. 【阅读笔记】《C程序员 从校园到职场》第八章 算法和协议(Part 2)

    原文链接: 让你提前认识软件开发(19):C语言中的协议及单元测试示例 CSDN博客 https://blog.csdn.net/zhouzhaoxiong1227/article/details/2 ...

  4. iOS 在工程内部创建一个静态库target

    当你在开发项目的时候需要把公用的东西打包出来,其他项目方便使用的时候,打包成静态库是你的最优选择,在工程内部开发的时候新建一个target进行静态库的开发可以使你的开发调试更加方便而不是单独新建一个工 ...

  5. private、public、protected和默认

    类中的域最好标记为private: 方法最好标记为public: private:仅对本类可见 public:对所有类可见 protected:对本包和对所有子类可见 默认(什么都不写):对本包可见 ...

  6. mybatis源码解析之环境准备

    概述 对于mybatis而言,大家一定都不陌生,我相信很多同学都跟我一样,用起来非常的熟练,但是其内部的实现原理呢,不太清楚,经常面试的时候,面试官问及这方面的知识,都只能尴尬的回答不知道,或者不清楚 ...

  7. 4.App非功能测试总结

    移动app测试的另一重要方面是移动app的非功能需求.移动app在推出市场或进行进一步开发前,移动测试员有许多需要测试的问题. 早期开发阶段要进行的第一个测试应该是实用性测试.通常是由alpha用户或 ...

  8. XQuery:查询任何可作为 XML 形态呈现的数据,包括数据库

    XQuery 也被称为 XML Query,被设计用来查询 XML 数据. 学习这个 需要知道 HTML / XHTML XML / XML 命名空间 XPath XML 实例文档 我们将在下面的例子 ...

  9. rootfs 制作

    最小 根文件系统 (1)/dev/console(终端控制台, 提供标准输入.标准输出以及标准错误) /dev/null (表示空设备终端, 所有写到这个文件中的数据都会被丢弃掉.) (2)init进 ...

  10. License控制解决方案

    当我们写完一个软件以后一般都会牵扯到软件控制,那么控制版本的原理是什么呢?其实就是在程序中添加了一段经过自己编写算法(这个算法可以是简单的公式运算,也可以是复杂的结合硬件的绑定方式),将形成的序列号注 ...