You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Application.GetContentStream() may fail if the app is in a path that contains a "#". #4781
Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
Problem description:
Application.GetContentStream() will fail if you place the executable in a path that contains "#".
Apparently, the paths after the "#" have disappeared.
Minimal repro:
For example, if you place the executable file and content file in "C:\FooBar\Path#Name\",
you will get the exception FileNotFoundException: Could not find file 'C:\FooBar\test.png'..
varuri=newUri("/test.png",UriKind.Relative);// test.png is content filevarstreamResourceInfo=Application.GetContentStream(uri);// <- Exception!!
Activity
Application.GetContentStream may fail
lindexi commentedon Jul 5, 2021
I wrote a demo in GitHub: https://github.com/lindexi/lindexi_gd/tree/e1022aededd1871017e4c43f228ad1fe26c99b57/ and I found that it seems is the Uri's bug, not the WPF
But I do not think the code in wpf is all right, such as ContentFilePart.cs
wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ContentFilePart.cs
Lines 106 to 130 in 323a02e
The
Application.ResourceAssembly.CodeBasewill return to the path that contains a#and the URI will be created by this string.Fix GetEntryAssemblyLocation Uri (#4799)
Fix GetStreamCore in ContentFilePart
Fix GetStreamCore in ContentFilePart
Test Application.GetContentStream() may fail
Fix GetStreamCore in ContentFilePart (#5066)
Fix GetStreamCore in ContentFilePart (#5066)
dipeshmsft commentedon Jan 6, 2023
Closing this issue as the corresponding fix has been merged in main branch