Why does (MLApp.MLApp)Marshal.GetActiveObject("MATLAB.Desktop.Application") return NULL?
古いコメントを表示
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.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Write COM Applications to Work with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!