Is there a way to use MWArray.DLL in a Windows Universal app?

5 次查看(过去 30 天)
I would like to call a simple Matlab function from inside a Universal Windows Platform (C#/XAML) program. I already compiled my function into a .Net Assembly using the Matlab Compiler SDK (deploytool).
I then create a new project with the Blank Template (Windows Universal) in Visual Studio 2015 (on Windows 10).
In order to specify the input and output arrays using Matlab types, I add a reference to MWArray.DLL, which was installed with the Matlab Compiler Runtime. (C:\Program Files\MATLAB\MATLAB Runtime\v90\toolbox\dotnetbuilder\bin\win64\v2.0\MWArray.dll) I also add the namespace at the top of my program. (using MathWorks.MATLAB.NET.Arrays;)
When I try to build it, I get the following compiler error: "Cannot find type System.ApplicationException in module CommonLanguageRuntimeLibrary."
Note that this happens even before I add my own DLL, so it must have something to do with the Matlab types in MWArray.DLL, which I do not have the source code for.
It works fine when I use it in a WPF (Desktop) Application instead of a UWP (Store) app, so it must have something to do with the Windows Universal references. Where can I find more information about what this error means and how to fix it (if possible)?

采纳的回答

D. du Toit
D. du Toit 2016-2-5
编辑:D. du Toit 2016-2-5
Made a ticket with MathWorks and this is the official answer for now:
"Unfortunately integrating MATLAB deployed .NET assembly with UWP applications is not supported as of now and not even in the R2016a release. UWP requires the application to be able to run on the Windows Runtime (WinRT) multi-platform architecture provided by Microsoft. WinRT does not support certain features of older .NET code, like the System.ApplicationException class, which the .NET assembly generated from MATLAB uses. For this reason the .NET deployed assembly is not going to run on WinRT."
So you will either have to use WPF or WinForms for now, or run the Matlab part as a separate service and just connect to it from a "thin-client" UWP app (similar to how you would use it on a website.)

更多回答(3 个)

Walter Roberson
Walter Roberson 2016-1-26
I do not know any of the details about this, but my understanding is that UWP is multi-architecture. That is a problem for MATLAB Compiler SDK because the libraries it calls upon are strictly x86 or x64 (possibly all that will be available from R2016a.) MATLAB Compiler SDK and MATLAB Compiler use the same underlying technology: they call into an OS- and architecture- dependent set of binaries.
It would be possible for Mathworks to create a UWP compatible Compiler SDK, I think, but there are some hidden complexities, such as getting working and efficient LAPACK and BLAS for each of the target architectures. Already there has to be differences between what is provided for Intel CPUs and AMD CPUs, and those differences sometimes cause problems and do lead to numeric differences in round-off. And getting the graphics support right...
It might happen, but I would not expect it to work yet; I would not expect it for R2016a either (and I say that as someone who has not looked at the R2016a preview at all.)
  1 个评论
D. du Toit
D. du Toit 2016-1-28
Yes, I noticed that the WPF application only worked when I compiled it specifically for x64 (same architecture as the DLL) and not x86 or AnyCPU. That didn't help with the UWP app, though. (It was also targeting x64, not x86 or ARM.) Hopefully it's just a reference issue that doesn't involve too many complexities. I haven't seen any details about R2016a either.

请先登录,再进行评论。


Bill Scott
Bill Scott 2017-7-17
is there any update on UWP application compatability using 2016b or 2017 versions of matlab?

Sergio
Sergio 2023-8-10
Is there any update on this for 2023a or 2023b?

类别

Help CenterFile Exchange 中查找有关 Deploy to C++ Applications Using mwArray API (C++03) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by