Fix NativeAOT COM custom query interface exception handling#117691
Merged
janvorli merged 2 commits intodotnet:mainfrom Jul 16, 2025
Merged
Conversation
After fixing a bug in the related stuff in coreclr, the regression test has revealed that the NativeAOT version has a similar issue. The exception stemming from the custom query interface are not caught and transformed to HRESULT, so they are reported as unhandled exceptions. This change adds try / catch to catch the exception and translate it to HRESULT.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes exception handling in NativeAOT COM custom query interface implementation to match a similar fix applied to CoreCLR. The issue was that exceptions from custom query interface calls were not being caught and converted to HRESULTs, causing them to be reported as unhandled exceptions instead of proper COM error codes.
- Adds try-catch block around custom query interface calls
- Converts caught exceptions to HRESULT return values
- Ensures consistent COM exception handling between CoreCLR and NativeAOT
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs
Outdated
Show resolved
Hide resolved
Member
Author
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jkoritzinsky
approved these changes
Jul 15, 2025
Member
jkoritzinsky
left a comment
There was a problem hiding this comment.
One comment otherwise LGTM
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs
Outdated
Show resolved
Hide resolved
Sergio0694
reviewed
Jul 15, 2025
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs
Show resolved
Hide resolved
Member
Author
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
AaronRobinsonMSFT
approved these changes
Jul 16, 2025
Member
Author
|
/ba-g the android test timing out is a known issue. |
This was referenced Jul 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After fixing a bug in the related stuff in coreclr, the regression test has revealed that the NativeAOT version has a similar issue. The exception stemming from the custom query interface are not caught and transformed to HRESULT, so they are reported as unhandled exceptions.
This change adds try / catch to catch the exception and translate it to HRESULT.
Close #117654