Main Content

NET.disableAutoRelease

Lock .NET object representing RunTime Callable Wrapper (COM wrapper)

Description

example

NET.disableAutoRelease(obj) locks a .NET object representing a RunTime Callable Wrapper (COM wrapper) so that MATLAB® does not release the COM object. After using the object, call NET.enableAutoRelease to release the COM object.

Examples

collapse all

Assume that the user-defined function GetComApp.m has access to a COM object defined in the pseudo-class ComNamespace.ComClass. One of its methods is readData, with the signature:

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

The input argument is defined in the pseudo-class NetDocTest.MyClass, which has a property named 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

The example in NET.enableAutoRelease shows how to call the GetComApp function.

Input Arguments

collapse all

.NET object representing a COM wrapper, specified as a COM wrapper class object.

Example: ComNamespace.ComClass

Version History

Introduced in R2010b