dotnet / dotnet/wpf

BitmapFrame: System.IO.FileFormatException: 'Unexpected property type or value.'

Open
#7,250 6 comments 0 reactions 0 assignees View on GitHub
needs more information
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 6.0
* Windows version: Windows 10 21H2
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

**Problem description:**
When creating a BitmapFrame from a MemoryStream, it throws a FileFormatException, on specific images:
`BitmapFrame Frame = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);`

Please note that when loading the same faulty image as a Resource and putting it into an Image in XAML, it does not has any issues.

**Actual behavior:**
It gives the following exception:
```
System.IO.FileFormatException: 'Unexpected property type or value.'
COMException: The bitmap property type is unexpected. (0x88982F8E)
```

**Expected behavior:**
I expect it not to throw an exception, and load correctly.

**Minimal repro:**
Please see this sample app I created: https://github.com/ZetaKebab/BitmapFrameIssue
The issue only happens with one of the two images (`cover1.jpg` is faulty, not `cover2.jpg`).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.