[vs17.14] Replace obsolete UCOMITypeInfo with recommended System.Runtime.InteropServices.ComTypes.ITypeInfo #12012
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.
Backport of #11940 to vs17.14
Fixes https://developercommunity.visualstudio.com/t/Unable-to-build-VBNET-app-in-VS2022--17/10867825
Work item (Internal use):
AB#2495104
Summary
ClickOnce users are running into an intermittent build failure in Forms/WPF projects with COM library references where the ClickOnce manifest creation task (
GenerateApplicationManifest
) fails. The Isolated property on the COM reference needs to be set to true for the failure to manifest.The
System.Runtime.InteropServices.UCOMITypeInfo.ReleaseTypeAttr
called in the ComImporter class throws a COMException when the task fails. The HResult in the exception is a random value instead of a standard HResult.Below is the msbuild stack when the ClickOnce task fails:
The fix is to replace the UCOMITypeLib/UCOMITypeInfo classes that were obsoleted in .NET 2.0 with the recommended ITypeLib/ITypeInfo classes from System.Runtime.InteropServices.ComTypes.
The root cause appears to be that
UCOMITypeInfo.ReleaseType
does not have the PreserveSig attribute which may be causing the .NET Interop layer to assume a HResult return value from the method. The method returns void which is likely causing COM Interop to throw a failure based on what the return value register contains.Customer Impact
Build failure in Forms/WPF projects with COM library reference when its Isolated property is set.
Regression?
No. There are reports of this failure on SO from several years ago. This is the first report on Developer Community feedback.
Testing
Intermittent failure is not reproducible after this change in the repro environment.
CTI test pass completed and signed off with the fix.
Risk
Low