compiled matlab .net assembly doesn't work on different computer
5 次查看(过去 30 天)
显示 更早的评论
I have a MATLAB function that I compile to a .NET-Assembly. The matlab library is then called in a .net wpf application. When I run the compiled program on my two development computers, at home and at work, the program works. When I install the program on the development computers the program works.
But after installing the program on another machine the program exits with an error message.
I have created the compiled matlab library on matlab 2019b update 7 and installed the matlab runtime 2019b on the computer that should run the program.
I checked with the Dependency Report generator what functions are called . The function uses functions from the following toolboxes:
- curve fitting
- statistics
- signal processing
- statistics and machine learning
- image processing
When my program didn't work with the matlab runtime, I deleted the runtime and installed matlab with all the toolboxes on the computer where I want to deploy my program. But the program still didn't work.
The .net application is targeted to x64 and runs on .net core 3.1. When the call to the matlab constructor is removed from the program the program works on the deployment computer. Besides .net core 3.1 the following .net frameworks are installed:
PSChildName Version
- v2.0.50727 2.0.50727.4927
- v3.0 3.0.30729.4926
- Windows Communication Foundation 3.0.4506.4926
- Windows Presentation Foundation 3.0.6920.4902
- v3.5 3.5.30729.4926
- Client 4.8.03761
- Full 4.8.03761
- Client 4.0.0.0
The MwArray.dll from matlab 2019b is deployed with the program.
So I can't think of anything else I could have done wrong. Does anyone have suggestions?
Below is the log of the error message:
2020-09-25 09:27:17.389 +02:00 [Information] Executable path:
2020-09-25 09:27:22.152 +02:00 [Error] System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'MyProgram.ViewModels.MainViewModel' that matches the specified binding constraints threw an exception.
---> System.Exception: MWArray assembly failed to be initialized
---> System.Exception: The MATLAB Runtime instance could not be initialized
---> System.ApplicationException: The MATLAB Runtime instance could not be initialized
segv - SEVERE ERROR
at MathWorks.MATLAB.NET.Utility.MWMCR..ctor(String componentId, String componentPath, Stream embeddedCtfStream, Boolean isLibrary)
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Utility.MWMCR..ctor(String componentId, String componentPath, Stream embeddedCtfStream, Boolean isLibrary)
at MyMatlabNamespace.MyMatlabClass..cctor()
--- End of inner exception stack trace ---
at MyMatlabNamespace.MyMatlabClass..ctor()
at MyProgram.ViewModels.AppBootStrapper.<>c.<.ctor>b__21_8()
0 个评论
回答(2 个)
Mohammad Sami
2020-9-28
You need to install the MATLAB runtime to use the .net assembly.
3 个评论
Mohammad Sami
2020-9-28
Ok. I missed that part. A few other users seems to have received the same errors. See if any of them help you.
https://www.mathworks.com/matlabcentral/answers/505208-mwarray-assembly-failed-to-be-initialized
https://www.mathworks.com/matlabcentral/answers/264138-dotnet-matlab-runtime-instance-could-not-be-initialized
Image Analyst
2020-9-28
Did the compilation create a file mccExcludedFiles.log? What is in it?
Do you call any applets, such as imtool, classification Learner, or any other things on the Apps tab? These can't be included in compiled code.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with MATLAB Compiler SDK 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!