WPF content files don't work with single-file
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### Description
Create a WPF application that uses [ContentFiles](https://docs.microsoft.com/en-us/dotnet/desktop/wpf/app-development/pack-uris-in-wpf?view=netframeworkdesktop-4.8#content-file-pack-uris)
When run outside single file this works and can load content.
When run under singlefile this fails because this throws:
https://github.com/dotnet/wpf/blob/eaece0ac93dd660dedcb33d9d908ea7485a8a636/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ContentFilePart.cs#L113
Resulting in null return value which later throws here:
https://github.com/dotnet/wpf/blob/eaece0ac93dd660dedcb33d9d908ea7485a8a636/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ContentFilePart.cs#L76
Most likely this ContentFilePart needs to "know" about single-file and be able to fetch it's content file.
```
System.ArgumentNullException: Value cannot be null. (Parameter 'baseUri')
at System.Uri..ctor(Uri baseUri, String relativeUri)
at MS.Internal.AppModel.ContentFilePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at MS.Internal.IO.Packaging.PackagePartExtensions.GetSeekableStream(PackagePart packPart, FileMode mode, FileAccess access)
at MS.Internal.IO.Packaging.PackagePartExtensions.GetSeekableStream(PackagePart packPart)
at System.Windows.Application.GetContentStream(Uri uriContent)
at wpf.MainWindow..ctor()
```
### Configuration
net5.0-windows, 5.0.0-rc.2.20464.8, publishSingleFile, win-x64
### Regression?
No, single file WPF didn't work until RC2
### Other information
Repro:
[wpf.zip](https://github.com/dotnet/runtime/files/5228736/wpf.zip)
To repro run `dotnet publish -p:PublishSingleFile=true -r:win-x64 -f:net5.0-windows`
Compare execution of normal vs single file app.
Contributor guide
Assessment
This issue has not been assessed yet.