Skip to content

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

Closed

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

Activity

  1. lncubus commented on May 9, 2022

    @lncubus
    Author

    Exception details
    ex1.txt

  2. lncubus commented on May 10, 2022

    @lncubus
    Author

    A minimal example for .NET 6
    LoadingImageSource_Net6.zip
    A minimal example for .Net Framework 4.8
    LoadingImageSource_Net48.zip

  3. lncubus commented on May 10, 2022

    @lncubus
    Author
  4. lindexi commented on May 11, 2022

    @lindexi
    Member

    @lncubus Thank you.

    Duplicate of #4781

    And I fixed it in #5066

  5. self-assigned this
    on May 11, 2022
  6. dipeshmsft commented on May 18, 2022

    @dipeshmsft
    Member

    Yeah, as @lindexi mentioned this is a duplicate of #4781, hence we are marking it closed as of now and will keep tracking the bug from the original issue. Also, we will take a look at the PR #5066 from @lindexi, to get to a resolution.

  7. ghost locked as resolved and limited conversation to collaborators on Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions