wrap_dll_csharp

版本 1.2.0.0 (10.3 KB) 作者: Dirk-Jan Kroon
Generates C# interface for a c++ DLL generated by the Matlab Coder
210.0 次下载
更新时间 2018/9/11

查看许可证

Function which generates a C# interface for a c++ DLL generated by the
Matlab Coder (with Visual Studio compiler).
Not only the external functions are wrapped also the structs, exposing
only managed classes and functions to the C# user.

Tested with Visual Studio 2017 in combination with Matlab ( Coder ) 2018a.

wrap_dll_csharp(filename_prj, filename_cs, namespace_cs, classname_cs, dllfilename_cs)

inputs:
(optional)
filename_prj : The coder project which generated coded
(example 'example.prj');
filename_cs : The full filename of the C-sharp file which will be written
(example 'example1.cs')
namespace_cs : The name space used in the C-sharp file,
(example, 'example1')
classname_cs : The class wrapping the external functions,
(example, 'example1_class')
dllfilename_cs : The full filename of the DLL file when using the c-sharp code,
(example, 'example1.dll')%

******* Example of calling the DLL through the generated C# code interface
// Matlab class input
var class1 = new class1();

// Double array 3x3 property of class
var data = new emxArray_real_T(3,3);

class1.Data = data;
// Set Text property of class
class1.Name = "test';
// Cell array output of matlab function
cell_0 b_Managed = new cell_0();

// Call initialize function made by the Matlab-coder
name_length_class.name_length_initialize();

// Call the c++ converted Matlab function
name_length_class.name_length(ref class1, ref b_Managed);
*********
Note, thus no more need to code DllImport, ASCIIEncoding or GCHandle.Alloc, this is all done by this C# interface generator.

引用格式

Dirk-Jan Kroon (2024). wrap_dll_csharp (https://www.mathworks.com/matlabcentral/fileexchange/67496-wrap_dll_csharp), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2018a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 MATLAB Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.2.0.0

Added support dynamic memory for variable sized function outputs

1.1.0.0

Now generates valid code, even when runtime checks are turned on. Now also supports returning single value instead of array or structure

1.0.0.0

changed title