Why does (MLApp.MLApp)Marshal.GetActiveObject("MATLAB.Desktop.Application") return NULL?
Mostra commenti meno recenti
I am attempting to create a COM connection to a running MATLAB instance from a .NET assembly with the code:
class Program
{
static void Main(string[] args)
{
//Variable
Type matlab;
object[] parameter = new object[1];
object mlObject;
try
{
matlab = Type.GetTypeFromProgID("Matlab.Application");
mlObject = Activator.CreateInstance(matlab);
object[] command = { "matlabroot" };
object testResult = (object)matlab.InvokeMember("Execute", System.Reflection.BindingFlags.InvokeMethod, null, mlObject, command);
....
On some machines this works with any MATLAB version I try it with, where as on others it will not work at all. In these cases, the function simply returns "NULL". This is resolved by using the MATLAB command "regmatlabserver", at which point it will work for any MATLAB instance. I would like to avoid this, as this command requires Admin rights.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Write COM Applications to Work with MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!