-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.Net Core 3.0 WPF Resource doesn't work in project #2258
Comments
You need to add |
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 |
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 |
@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. |
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 |
@nguerrera, @dsplaisted can we do something to prevent inclusion of .NET Framework's |
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? |
Can you elaborate a bit? |
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? |
If you want to use image resources a bit more generally, you might want to investigate |
So, to fix it you just need to change <Project Sdk="Microsoft.NET.Sdk"> to <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> in your project file |
I added |
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
The text was updated successfully, but these errors were encountered: