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

3 views (last 30 days)
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)?

Accepted Answer

D. du Toit
D. du Toit on 5 Feb 2016
Edited: D. du Toit on 5 Feb 2016
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.)

More Answers (3)

Walter Roberson
Walter Roberson on 26 Jan 2016
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 Comment
D. du Toit
D. du Toit on 28 Jan 2016
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.

Sign in to comment.


Bill Scott
Bill Scott on 17 Jul 2017
is there any update on UWP application compatability using 2016b or 2017 versions of matlab?
  1 Comment
Walter Roberson
Walter Roberson on 17 Jul 2017
For the reasons I listed above about architecture, I would not expect this to be possible for some time.

Sign in to comment.


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

Community Treasure Hunt

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

Start Hunting!