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
Guillaume 2016년 6월 16일

0 개 추천

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에 대해 자세히 알아보기

질문:

2016년 6월 16일

답변:

2016년 6월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by