masiboo
masiboo

Reputation: 4719

.net core 2.0 generated simple console application error

I'm using windows 10 and visual studio 2017 to generated simple console application for .net core 2.0 framework. In the app I'm trying to show

MessageBox.Show("Test msg");

    using System;
    using System.Windows.Forms; // error

    namespace Window
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
                MessageBox.Show("Message from main (primary) thread"); // error
                Console.ReadLine();
            }
        }
    }

In the generated project it adds dependencies SDK -> Microsoft.NETCore.App -> System.Windows.dll.

Why do I still get this error?

Upvotes: 0

Views: 324

Answers (1)

mason
mason

Reputation: 32699

Windows Forms is not part of .NET Core. Windows Forms is part of the .NET Framework . You would need to pick a GUI library implemented on top of .NET Core or switch to using .NET Framework if you still want to use Windows Forms. Refer to the diagram below.

enter image description here

Upvotes: 4

Related Questions