Not able to Call C# Function from MATLAB Script
Mostrar comentarios más antiguos
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 ?
Respuestas (1)
Guillaume
el 16 de Jun. de 2016
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
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!