Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-10, 16:49   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 从服务的环境变量路径加载dll

我们在计算机上安装Matlab Runtime,然后重新启动.net Windows服务,该服务从Matlab Runtime调用方法。
问题在于,在重新启动Windows之前,我们会收到TypeInitializationException错误。我们认为发生这种情况是因为环境变量直到重新启动后才在服务上更改,并且Matlab使用%Path%变量引用其核心DLL。
我的问题是,您认为我可以更改%Path%变量,以便Matlab在为其引擎引用核心dll时使用它吗?
还是可以在.NET的运行时DLL加载机制中添加目录,以便在不重新启动计算机的情况下正确引用那些Matlab核心dll?

这是我们得到的例外

System.TypeInitializationException: The type initializer for 'MatlabCalculation.Calculation' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'mclmcrrt710.dll': Kan opgegeven module niet vinden. (Exception from HRESULT: 0x8007007E) at MathWorks.MATLAB.NET.Utility.MWMCR.mclmcrInitialize() at MathWorks.MATLAB.NET.Utility.MWMCR..cctor() --- End of inner exception stack trace --- at MatlabCalculation.Calculation..cctor() --- End of inner exception stack trace --- at MatlabCalculation.Calculation.Finalize() “ Kan opgegeven module niet vinden” =“找不到指定的模块”


回答:
如果可以重写服务,则可以在.NET代码中使用System.Environment .GetEnvironmentVariable和SetEnvironmentVariable方法,并自己添加Matlab运行时引擎路径。如果无法重写服务,则可以尝试对服务起作用的net stop / net start或installutil 。或者您可以在ServerFault上询问。

老答案,因为我误解了这个问题:

是MATLAB组件启动后引发异常吗?如果是这样,则CTFROOT,TOOLBOXDIR和ADDPATH函数可能会有所帮助。也许像:

if isdeployed addpath(ctfroot); addpath(toolboxdir('signal')); %more addpath(toolboxdir('toolboxname')) statements end 但是,如果根本不启动MATLAB,这将无济于事。



更多&回答...
poster 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 03:21


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.