필터 지우기
필터 지우기

How can I interface a C# created .NET assembly with MATLAB?

조회 수: 28 (최근 30일)
I have created a .NET assembly using C# and would like to know how can I interface it with MATLAB.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2022년 5월 25일
편집: MathWorks Support Team 2022년 5월 25일
This enhancement has been incorporated in Release 2009a (R2009a). For previous product releases, read below for any possible workarounds.
There are two possible cases:
1. If you already have the assembly:
The assembly should be COM visible to interface with MATLAB. This can be done by generating the Type-Library using the 'tlbexp.exe' utility, which comes with the Microsoft .NET Framework SDK. This utility can be found under the installation directory of MS Visual Studio, for example, 'C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0'.
To create the Type-Library, follow these steps:
1. Click on 'Start->Programs->.NET Framework SDK->SDK Command Prompt'.
2. Bring your C# DLL to this folder. Now execute:
tlbexp myDLL.dll /out:myDLL.tlb
3. To deploy the DLL, register it using the 'regasm' utility, which comes with Microsoft .NET Framework, for example, under 'C:\WINNT\Microsoft.NET\Framework\v2.0.50727' :
regasm /codebase myDLL.dll /tlb:myDLL.tlb
2. If you are about to write code to generate the assembly:
Ensure that the assembly is COM compliant. For example, Microsoft Visual Studio gives the option to configure the generated assembly to be 'COM Visible'. This should automatically generate the required Type-Library when the assembly is built. When deploying the assembly, make sure that it is registered using the 'regasm' utility with '/codebase' option as in (1) above.
For more information on 'regasm' refer to:
To interface the assembly with MATLAB, use the ACTXSERVER command:
h=actxserver('myDLLProgID')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler SDK에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by