In the process of developing WPF program based on .NET Core 3, there is a need to encapsulate tool classes such as converter and formatter into another class library for reuse.

Therefore, after creating a new. Net core class library, copy the class file into it, and System.Windows.Data will be inaccessible when compiling!

It's strange that the new class library and the framework of the original WPF program are Microsoft.NETCore.App.

Originally, in the description file of the class library, you need to specify the type of SDK , as follows:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">




1.Change <Project Sdk="Microsoft.NET.Sdk"> to <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

2.Add <UseWPF>true</UseWPF> to node PropertyGroup

In addition, there will be such problems in ASP.NET Core 3.0 web projects. Also, change <Project Sdk="Microsoft.NET.Sdk"> to <Project Sdk="Microsoft.NET.Sdk.Web">

If the class library is compiled and output as executable file, it may be OutputType is set to Exe by default. You need to modify or add <OutputType>Library</OutputType> in the PropertyGroup node, and define its output as a class library!

Like The Article To View All

All Comments

Leave a Reply Cancel Reply

Tips: Your email address will not be disclosed!

If you can't see clearly,please click to change...