This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
Merge changes from TFS - #1505
Merged
Merged
Conversation
When looking at a dump, I realized our code below doesn't really do anything:
return new InvalidCastException(String.Format(
SR.InvalidCast_Com,
comObjectDisplayName,
interfaceDisplayName,
interfaceType.GetInterfaceGuid().ToString("B").ToUpper(),
errorMessage));
Because SR.InvalidCast_Com is "InvalidCast_Com" and rest of the args get lost. Switching to SR.Format fixes this since it would concat the rest of the arguments to InvalidCast_Com so the message is still useful.
I'm adding il2ilcr to broaden the awareness - it is pretty costly to have one of those bugs since you lose valuable insight (like in the dump case we lost the HRESULT and error message in the failed QI). I did a scan in System.Private.Interop and fixed all instances.
The new error message is (ignore the apparently successful message since I forgot to change the HR when I force the error path).
0:000> du 0x01b563cc+0x8
01b563d4 "InvalidCast_ComSystem.__ComObjec"
01b56414 "t, MissingMetadataType, {F5EA435"
01b56454 "E-A7DB-37E0-B506-A9B69802CDD1}, "
01b56494 "The operation completed successf"
01b564d4 "ully. (Excep_FromHResult 0x0). F"
01b56514 "or more information, visit http:"
01b56554 "//go.microsoft.com/fwlink/?LinkI"
01b56594 "d=623485"
This is apparently much more useful than "InvalidCast_Com" :)
[tfs-changeset: 1617170]
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.
No description provided.