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.
Best Answer