Skip to content

Commit 7facd01

Browse files
Clarify IReflect interface COM casting behavior
Updated remarks to clarify COM object casting behavior in .NET versions.
1 parent ac0c84f commit 7facd01

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

xml/System.Reflection/IReflect.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@
5555
<format type="text/markdown"><![CDATA[
5656
5757
## Remarks
58-
The <xref:System.Reflection.IReflect> interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). <xref:System.Reflection.IReflect> defines a subset of the <xref:System.Type> reflection methods. Implementing this interface enables a type to customize its behavior when the object is being accessed from COM as an `IDispatch` object. The <xref:System.Runtime.InteropServices.CustomMarshalers.ExpandoToDispatchExMarshaler> class can be used to marshal an object that implements <xref:System.Reflection.IReflect> or <xref:System.Runtime.InteropServices.Expando.IExpando> as a COM `IDispatch` object, and vice versa.
58+
Since .NET 10, no COM object can be successfully cast to this interface. It is recommended to project and define a managed definition of `IDispatch` or `IDispatchEx` if access is needed.
5959
60+
From .NET 5 until .NET 9, COM objects that implement `IDispatchEx` can be cast to this interface, but all methods will throw an exception.
61+
62+
On .NET Framework, the <xref:System.Reflection.IReflect> interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). <xref:System.Reflection.IReflect> defines a subset of the <xref:System.Type> reflection methods. Implementing this interface enables a type to customize its behavior when the object is being accessed from COM as an `IDispatch` object. The <xref:System.Runtime.InteropServices.CustomMarshalers.ExpandoToDispatchExMarshaler> class can be used to marshal an object that implements <xref:System.Reflection.IReflect> or <xref:System.Runtime.InteropServices.Expando.IExpando> as a COM `IDispatch` object, and vice versa.
63+
6064
]]></format>
6165
</remarks>
6266
<altmember cref="T:System.Runtime.InteropServices.CustomMarshalers.ExpandoToDispatchExMarshaler" />

0 commit comments

Comments
 (0)