Main Content

NET.disableAutoRelease

锁定表示运行时可调用包装器(COM 包装器)的 .NET 对象

说明

示例

NET.disableAutoRelease(obj) 锁定表示运行时可调用包装器(COM 包装器)的 .NET 对象,以阻止 MATLAB® 释放 COM 对象。正常使用对象之后,调用 NET.enableAutoRelease 释放 COM 对象。

示例

全部折叠

假设用户定义函数 GetComApp.m 可访问伪类 ComNamespace.ComClass 中定义的 COM 对象。其中一个方法是 readData,带有以下签名:

System.String RetVal readData(ComNamespace.ComClass this, System.String strIn)

输入参数在伪类 NetDocTest.MyClass 中定义,该类有一个名为 MyApp 的属性。

function GetComApp(obj)
comObj = ComNamespace.ComClass;
obj.MyApp = comObj;
% To pass a COM object to another process, lock the object
NET.disableAutoRelease(comObj);
end

NET.enableAutoRelease 中的示例显示如何调用 GetComApp 函数。

输入参数

全部折叠

表示 COM 包装器的 .NET 对象,指定为 COM 包装器类对象。

示例: ComNamespace.ComClass

版本历史记录

在 R2010b 中推出