How can I interface a C# created .NET assembly with MATLAB?
27 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2009 年 6 月 27 日
編集済み: MathWorks Support Team
2022 年 5 月 25 日
I have created a .NET assembly using C# and would like to know how can I interface it with MATLAB.
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler SDK についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!