Reputation: 227
I'm trying to reference PresentationCore.dll and PresentationFramework.dll in .NET 5 API but apparently it requires also WindowsBase, this is the error I get:
"System.TypeLoadException: Could not load type 'System.Windows.DependencyObject' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."
If I try to add reference to Windows.Base, it shows error in Visual Studio:
Upvotes: 10
Views: 18364
Reputation: 28766
What you want to do is to add a WPF reference. This is not required if your csproj includes the net5.0-windows
entry for TargetFramework
and <UseWPF>true</UseWPF>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>
This UseWPF
entry automatically adds all WPF references and you can use WPF calls.
Upvotes: 29