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 ?

Risposte (1)

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

Categorie

Richiesto:

il 16 Giu 2016

Risposto:

il 16 Giu 2016

Community Treasure Hunt

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

Start Hunting!

Translated by