ComWrappers.GetOrCreateComInterfaceForObject Method

Definition

Creates a COM representation of the supplied object that can be passed to a non-managed environment.

C#
public IntPtr GetOrCreateComInterfaceForObject(object instance, System.Runtime.InteropServices.CreateComInterfaceFlags flags);

Parameters

instance
Object

The managed object to expose outside the .NET runtime.

flags
CreateComInterfaceFlags

Flags used to configure the generated interface.

Returns

IntPtr

The generated COM interface, as a pointer to the IUnknown interface implementation, that can be passed outside the .NET runtime.

Remarks

If a COM representation was previously created for the specified instance using this ComWrappers instance, the previously created COM interface will be returned. If not, a new one will be created.

Applies to

Product Versions
.NET 5, 6, 7, 8, 9