【发布时间】:2019-07-19 16:22:01
【问题描述】:
尝试在 docker 映像上安装 Matlab 运行时以及我正在处理的项目,该项目是一个引擎,将根据给定的内容运行各种测量,其中许多测量使用 Matlab。当我运行 docker 时,虽然我收到“MWArray 程序集无法初始化”或缺少 matlab dll 的错误。
由于公司要求,我正在尝试在 Docker for Windows 中运行它,但无法成功让 DockerFile 识别 MCR。下面是我一直在使用的将 MCR 放到 docker 上的代码。
FROM mcr.microsoft.com/dotnet/framework/runtime:4.7.2-windowsservercore-ltsc2019
ADD http://ssd.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/win64/MCR_R2017b_win64_installer.exe C:\\MCR_R2017b_win64_installer.zip
# Line 3: Use PowerShell
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Line 4: Unpack ZIP contents to installation folder
RUN Expand-Archive C:\\MCR_R2017b_win64_installer.zip -DestinationPath C:\\MCR_INSTALLER
# Line 5: Run the setup command for a non-interactive installation of MCR
RUN Start-Process C:\MCR_INSTALLER\bin\win64\setup.exe -ArgumentList '-mode silent', '-agreeToLicense yes' -Wait
# Line 6: Remove ZIP and installation folder after setup is complete
RUN Remove-Item -Force -Recurse C:\\MCR_INSTALLER, C:\\MCR_R2017b_win64_installer.zip
WORKDIR /app
COPY /Project/bin/Debug/*.dll ./
COPY /Project/bin/Debug/Project.exe .
ENTRYPOINT ["C:\\app\\Project.exe"]
编辑:我想我已经找到了一个可行的解决方案,遵循其他 anwser 关于 ltsc2019 不适用于 Matlab 2017b 的想法。以下代码已在 docker 内与 2017b 一起使用。
FROM mcr.microsoft.com/windows:1809
【问题讨论】:
-
将matlab dll放到其他.cs文件所在的项目文件夹中。然后在项目菜单中:添加现有项目并浏览 matlab dll。在解决方案资源管理器中右键单击 dll 并在属性中选择“复制到输出目录”,这会将 dll 添加到项目并自动安装。
-
当您说 matlab dll 时,您是指在 C:\Program Files\MATLAB 中找到的所有 dll 吗?
-
没有。程序文件夹是必须安装在机器上的运行时。 Matlab 有一个编译选项,允许您创建一个 dll(来自 .m 文件),该 dll 仅在安装运行时时执行。您需要在 c# 可执行文件所在的 c# 文件夹中编译的 dll 文件。当您运行 setup.exe 时,已编译的 dll 将安装在部署机器上。 (或已安装)。
-
在路径 Solution/Project/bin/Debug/ 我有我想要的 dll 和 project.exe,我构建了 docker 然后运行它。在运行期间,我收到此错误“Loading C:\Program Files\MATLAB\MATLAB Runtime\v93\bin\win64\matlab_startup_plugins\lmgrimpl\libmwlmgrimpl.dllfailed with error: The specified module could not be found.”
-
C# 项目使用 .NET Framework 4.7.1,目标是 x64。
标签: c# .net windows matlab docker