I have a console application and I just want to display a MessageBox
at some point.
I found a page that stated that I could do it by adding a reference to the assembly. However, just adding using System.Windows.Forms
doesn't work (CS02348: it doesn't exist in the namespace and I'm probably missing an assembly reference).
However, I can only seem to add COM references to my project. When I looked for a way to display the assembly panel, I found this page that seems to state that I should already have it.
According to this tutorial, I should manually browse and seek in C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App
.
I tried with C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\7.0.2\System.Windows.Forms.dll
and C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.13\System.Windows.Forms.dll
. With both of them, I get the error CS1705:
Error CS1705 Assembly 'System.Windows.Forms' with identity 'System.Windows.Forms, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' uses 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I just deleted the System.Windows.Forms.dll I manually imported and my *.csproj
file looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="RandomLibrary">
<HintPath>RandomLibrary.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
I need it to stay in 6.0 for the LTS.
Why don't I have this assembly tab? How to add reference to System.Windows.Forms? Why did I get the same message with version 6.0.13 than with version 7.0.2?