Skip to content

Commit 9894846

Browse files
AaronRobinsonMSFTCopilotgewarren
authored
Clarify IReflect interface COM casting behavior (#12051)
Updated remarks to clarify COM object casting behavior in .NET versions. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
1 parent 6efe999 commit 9894846

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

xml/System.Reflection/IReflect.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +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+
59+
In .NET 10 and later versions, no COM object casts successfully to this interface. If you need access, it's recommended to project and define a managed definition of `IDispatch` or `IDispatchEx`.
60+
61+
In .NET 5 through .NET 9, COM objects that implement `IDispatchEx` can be cast to this interface, but all methods throw `TypeLoadException`.
62+
63+
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.
5964
6065
]]></format>
6166
</remarks>

0 commit comments

Comments
 (0)