Can I generate a .NET dll that imports other .NET assembly?

5 visualizzazioni (ultimi 30 giorni)
Hi!,
This might sound weird, but I want to use a .NET assembly on Matlab (I already know how to do this), make some functions with it, and then generate a .NET .dll with the compile tool. My question is, will the compile tool complain about the usage of external code?
The situation is as follows: I was given a C# programmed API, which I have to implement. I have to create other functions, which consume the API. I would like to make these other functions in Matlab, since I have much more experience there than in C#. The thing is that these functions have to be exported to another program, via dll (this is not optional). So, I was thinking to compile these new functions into a new .NET assembly.
Thanks a lot in advance!

Risposta accettata

Kojiro Saito
Kojiro Saito il 3 Dic 2018
Yes, you can use external .NET dll in compiled MATLAB function.
For example, assume the name of external dll is 'dotNetExternalClass.dll'. In MATLAB function, you can load that dll with full path.
function out = compileOtherDll(in1, in2)
externalDllPath = fullfile(pwd, 'dotNetExternalClass.dll');
asm = NET.addAssembly(externalDllPath);
% do something
% ...
% ...
end
Then, compile this function as .NET assembly using deploytool. compileOtherDll.dll will be created in this case.
After that, in Visual Studio, it's needed to add compileOtherDll.dll and $MATLAB_INSTALL\toolbox\dotnetbuilder\bin\win64\v4.0\MWArray.dll as references and add "using" in C# codes.
using MathWorks.MATLAB.NET.Arrays;
using compileOtherDll;
After building this C# codes, you need to place the external dll (dotNetExternalClass.dll) in the same folder of exe file.
  3 Commenti
Kojiro Saito
Kojiro Saito il 3 Dic 2018
Yes, I don't think there's a concern of using compiled dll from a propietary software, too. What messages did you get by deploytool?
On the end users' PCs, installation of MATLAB Runtime is necessary. Instead of MATLAB, MATLAB Runtime works with compiled applications/libararies.
Alejandro Wechsler
Alejandro Wechsler il 3 Dic 2018
Nono, I haven't tried it yet.
Thanks for replying, it has been extremely usefull.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB Compiler SDK in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by