Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up.Net Core 3.0 WPF Resource doesn't work in project #2258
Comments
This comment has been minimized.
This comment has been minimized.
You need to add |
This comment has been minimized.
This comment has been minimized.
In addition to You are not building a WPF or WinForms application yet - what you are building is just a .NET Core library with a name like WpfApp.
You can type |
This comment has been minimized.
This comment has been minimized.
We have tried to help users who get into these sorts of situations by showing warnings. I wonder if it might be worthwhile to look for common WPF items like |
This comment has been minimized.
This comment has been minimized.
@weltkante @vatsan-madhavan After adding the We can add both net48 and netcoreapp3.0 into all the project csproj files and then we can choose which TargetFramework to run. But if we run in net48, no Exception occurs but in netcoreapp3.0, there will be an IOException. Only compiling in netcoreapp3.0 the Resource is not build into the assembly. |
This comment has been minimized.
This comment has been minimized.
The attached repro "works" when building for net48 (or any .NET Framework target) due to a bug - it's not supposed to work (I'll explain the bug in detail further down). In fact, having a .NET Framework If we attempt to build the project using The "bug" is this: In SDK style projects, we didn't intend for WPF specific functionality to be present unless In the attached project, This bug doesn't present itself when building .NET Core TargetFrameworks, and so when building |
This comment has been minimized.
This comment has been minimized.
@nguerrera, @dsplaisted can we do something to prevent inclusion of .NET Framework's |
This comment has been minimized.
This comment has been minimized.
I have just reset the project with and Microsoft.NET.Sdk.WindowsDesktop ,it works fine. So, is there a way to share the resource between WPF .Net Core and Asp .Net Core? |
This comment has been minimized.
This comment has been minimized.
Can you elaborate a bit? |
This comment has been minimized.
This comment has been minimized.
Oh, sure. Like I have two projects, one is WPF .Net Core and the other is WindowsForm .Net Core ( or ASP .Net Core ). An image is needed by both projects. So I want to add a project which is based on .Net Core to manage this image. But how I can make this works for both projects? |
This comment has been minimized.
This comment has been minimized.
If you want to use image resources a bit more generally, you might want to investigate |
dotnet --info
)winver
)Problem description:
In WpfApp1 I use this BitmapImage in my xaml
when I run WpfApp1 I got an error:

And we decompile the Wpf.app.test.dll found that there is no Image in the Dll. ( I have set image's build action to Resource )
The Wpf.app.test.project code
The Decompile result:

Actual behavior:
Expected behaviour:
Minimal repro:
Here is the demo for this bug
WpfApp1.zip