Skip to content

Conversation

@AaronRobinsonMSFT
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT commented Jul 3, 2024

Instead of simply casting to IDispatch*, we now QI on managed types. This was uncovered in an out-of-proc COM scenario.

This introduces a subtle code change that now generates an error in CoreCLR.

COMPlusThrow(kTargetInvocationException, IDS_EE_INTERFACE_NOT_DISPATCH_BASED);

The above API will fail since it assumes the target type has a default constructor. The TargetInvocationException doesn't have one and instead of this propogating back up to managed it would result in a MissingMethodException for .ctor, which is very confusing. This PR changes all uses of the above to instead throw a kTargetException, which is technically different from .NET Framework, but since no one would have seen the TargetInvocationException behavior it seems like a harmless change.

Instead of simply casting to IDispatch, we now QI on managed types.
This was uncovered in an out-of-proc COM scenario.
@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 0dd2a62 into dotnet:main Jul 9, 2024
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the handle_missing_idispatch branch July 9, 2024 18:00
matouskozak added a commit to matouskozak/runtime that referenced this pull request Jul 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants