Marshal.SetComObjectData Method (Object, Object, Object)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

public static bool SetComObjectData(
	object obj,
	object key,
	object data


Type: System.Object

The COM object in which to store the data.

Type: System.Object

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

Type: System.Object

The data to set.

Return Value

Type: System.Boolean

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

Exception Condition

obj is null.


key is null.


obj is not a COM object.


obj is a Windows Runtime object.

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.


requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

.NET Framework
Available since 1.1
Return to top