Documentation Center

  • Trial Software
  • Product Updates

NET.disableAutoRelease

Package: NET

Lock .NET object representing a RunTime Callable Wrapper (COM Wrapper) so that MATLAB does not release COM object

Syntax

A = NET.disableAutoRelease(obj)

Description

A = NET.disableAutoRelease(obj) locks a .NET object representing a RunTime Callable Wrapper (COM Wrapper) so that MATLAB® does not release the COM object. obj is a .NET object representing a COM Wrapper.

Before passing a .NET object representing a COM Wrapper to another process, lock the object using this function so that MATLAB does not release it. After using the object, call NET.enableAutoRelease to release the COM object.

Examples

The following user-defined function, GetComApp.m, has access to a COM object defined in the pseudo-classComNamespace.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.

See Also

Was this topic helpful?