diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadata.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadata.cs index 3ac48a36f58..7e501b12286 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadata.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapMetadata.cs @@ -265,24 +265,16 @@ public int InitializeFromBlockReader( { Invariant.Assert(pIBlockReader != IntPtr.Zero); - int hr = MS.Win32.NativeMethods.S_OK; - - UInt32 count = 0; - Guid guidVendor = new Guid(MILGuidData.GUID_VendorMicrosoft); - List metadataBlocks = new(); - - hr = UnsafeNativeMethods.WICMetadataBlockReader.GetCount( - pIBlockReader, - out count - ); - + int hr = UnsafeNativeMethods.WICMetadataBlockReader.GetCount(pIBlockReader, out UInt32 count); if (HRESULT.Succeeded(hr)) { + List metadataBlocks = new((int)count); + using (FactoryMaker factoryMaker = new FactoryMaker()) { - for (UInt32 i=0; i