From 7facd01428044f326b90b8e379b1df5d60909505 Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Sat, 15 Nov 2025 13:50:48 -0800 Subject: [PATCH 1/3] Clarify IReflect interface COM casting behavior Updated remarks to clarify COM object casting behavior in .NET versions. --- xml/System.Reflection/IReflect.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xml/System.Reflection/IReflect.xml b/xml/System.Reflection/IReflect.xml index a0efb4c0941..fe2306c968e 100644 --- a/xml/System.Reflection/IReflect.xml +++ b/xml/System.Reflection/IReflect.xml @@ -55,8 +55,12 @@ interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). defines a subset of the 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 class can be used to marshal an object that implements or as a COM `IDispatch` object, and vice versa. + 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. + From .NET 5 until .NET 9, COM objects that implement `IDispatchEx` can be cast to this interface, but all methods will throw an exception. + + On .NET Framework, the interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). defines a subset of the 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 class can be used to marshal an object that implements or as a COM `IDispatch` object, and vice versa. + ]]> From 7be62f694509547ba8a55888066a966ed90ef1d7 Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Sat, 15 Nov 2025 14:01:39 -0800 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- xml/System.Reflection/IReflect.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xml/System.Reflection/IReflect.xml b/xml/System.Reflection/IReflect.xml index fe2306c968e..9e9f449e0f0 100644 --- a/xml/System.Reflection/IReflect.xml +++ b/xml/System.Reflection/IReflect.xml @@ -55,12 +55,12 @@ interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). defines a subset of the 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 class can be used to marshal an object that implements or as a COM `IDispatch` object, and vice versa. - + ]]> From 6c3d21f5d2f446124606817f620ae95c7da739a2 Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Mon, 17 Nov 2025 09:10:00 -0800 Subject: [PATCH 3/3] Update xml/System.Reflection/IReflect.xml Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- xml/System.Reflection/IReflect.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xml/System.Reflection/IReflect.xml b/xml/System.Reflection/IReflect.xml index 9e9f449e0f0..73045db606f 100644 --- a/xml/System.Reflection/IReflect.xml +++ b/xml/System.Reflection/IReflect.xml @@ -55,11 +55,12 @@ interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). defines a subset of the 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 class can be used to marshal an object that implements or as a COM `IDispatch` object, and vice versa. +In .NET 5 through .NET 9, COM objects that implement `IDispatchEx` can be cast to this interface, but all methods throw `TypeLoadException`. + +On .NET Framework, the interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). defines a subset of the 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 class can be used to marshal an object that implements or as a COM `IDispatch` object, and vice versa. ]]>