Not able to Call C# Function from MATLAB Script
古いコメントを表示
I am using below C# function :
[InterfaceType(ComInterfaceType.InterfaceIsDual), Guid("XXXXX-XXXX-XXXX-XXXX-XXXXXXX")]
public interface ILauncher
{
void launch();
}
[ClassInterface(ClassInterfaceType.None), Guid("YYYYYYY-YYYY-YYYY-YYYY-YYYYYYY"), ProgId("ActiveXObjects.Launcher")]
public class Launcher : ILauncher
{
public void launch()
{
Console.WriteLine("I launch scripts for a living.");
}
}
I want this C# function to be called from my MATLAB Script : like this : net = actxserver('ActiveXObjects.Launcher');
net.launch()
But I am not able to Launch Console Window,I am Expecting output as "I launch scripts for a living.".
Can anyone please suggest am I doing something wrong ?
Simply I am getting ActiveX on Command window whenever I run the Script.
Is this a right way to call C# Function from MATLAB ?
回答 (1 件)
Guillaume
2016 年 6 月 16 日
There is no need to give your .Net class a dual interface, nor is there any need to go through COM to call .Net code from matlab. You can call .Net code directly from matlab.
Something like this should work:
NET.addAssembly('fullpathtoyourassembly');
YourAssemblyName.Launcher.launch
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!