Tag Archives: .net core

How to Solve .Net Core Class Library Import System.Windows.Forms Error

Net Framework framework references are mostly added directly on the Internet
But this method of packaging is very unfriendly

After going through the Microsoft documentation, I found a direct reference to the System. Froms assembly. It is also hidden deep, at: link

Net Core version >= 3.0

In fact, just modify the project’s csproj file

The original file

<Project Sdk=”Microsoft.NET.
<PropertyGroup
<TargetFramework>netcoreapp3.1</TargetFramework
<OutputType>Library</OutputType>
</PropertyGroup>
</Project>.
Modify the SDK in the first line

<Project Sdk=”Microsoft.NET.Sdk.WindowsDesktop”>
<PropertyGroup
<TargetFramework>netcoreapp3.1</TargetFramework
<OutputType>Library</OutputType>
</PropertyGroup>
</Project>.
Note this extra WindowsDesktop

Just add this reference to find System.Windows.