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"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <UseWPF>true</UseWPF> </PropertyGroup> </Project>
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!
- 版权声明： 本博客所有文章和照片除特别声明外，转载请联系作者获取授权，并请注明出处！