Skip to content

Image Source fails to load an image if application path has hash sign in it #6560

@lncubus

Description

@lncubus
  • .NET Core Version: 6.0.4
  • Windows version: Windows 11 21H2
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

Problem description:
It is possible to specify Image source with relative path in XAML definition:
Icon="Images/app.dark.png"
However, this definition fails to load image if the path containing application has # symbol.

Actual behavior:
In .Net 6
Fails in BitmapDecoder.SetupDecoderFromUriOrStream with System.IO.DirectoryNotFoundException
which transforms to exception going out:
System.Windows.Markup.XamlParseException: "System.Windows.Baml2006.TypeConverterMarkupExtension" throws an exception."

Expected behavior:
We should load image with relative path without crash.

Minimal repro:

  1. Create a WPF application
  2. Add image in subfolder and specify its Build Action as Content and Copy to Output Directory as Copy or Copy if newer
  3. Specify main window Icon image with relative path
    <Window x:Class="WpfApp1.MainWindow" Icon="Images/app.dark.png">
  4. Start an application and check everything is okay
  5. Rename the project path into #WpfApp1
  6. Start an application
  7. Get an exception shown above

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions