N
N
Nikita2020-11-27 12:54:48
.NET
Nikita, 2020-11-27 12:54:48

How to connect System.Windows.Forms in .Net 5 Console Application?

Good afternoon, I transferred the application from 4.7.2 to .Net 5, it was possible to use the OpenFileDialog class from System.Windows.Forms, the connection to using did not work, I tried to put Microsoft.Windows.Compatibility from NuGet, but it was also empty there. I googled a couple of options with a change to both net5.0-windows and WinExe, respectively, but it didn’t help, the Output Type of the application changed to Windows Application and it did not start

Screenshots

5fc0cca60d929395438486.png
5fc0ccba864b0407252314.png
5fc0ccc0d39cb499491627.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Nikolaev, 2020-11-27
@paulox

Right click on Links->Add Link->Find System.Windows.Forms ->Checking the box doesn't help?
5fc0d434f006c523495659.png

V
Vasily Bannikov, 2020-11-27
@vabka

This is how csproj creates .net cli when you dodotnet new winforms

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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>

</Project>

Here is another detailed guide: https://docs.microsoft.com/en-us/dotnet/desktop/wi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question