Marshal.SetComObjectData(Object, Object, Object) Method

Definition

Sets data referenced by the specified key in the specified COM object.

C#
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static bool SetComObjectData(object obj, object key, object? data);
C#
public static bool SetComObjectData(object obj, object key, object data);
C#
public static bool SetComObjectData(object obj, object key, object? data);
C#
[System.Security.SecurityCritical]
public static bool SetComObjectData(object obj, object key, object data);

Parameters

obj
Object

The COM object in which to store the data.

key
Object

The key in the internal hash table of the COM object in which to store the data.

data
Object

The data to set.

Returns

true if the data was set successfully; otherwise, false.

Attributes

Exceptions

obj is null.

-or-

key is null.

obj is not a COM object.

-or-

obj is a Windows Runtime object.

Remarks

All COM objects wrapped in a Runtime Callable Wrapper (RCW) have an associated hash table, to which SetComObjectData adds data. Marshal.GetComObjectData retrieves data from the hash table. You should never have to call either method from your code.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.1

See also