C# Console application does not show System.Windows.Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a C# console application and I need pop up a Messagebox. However the
IntelliSense
does not show for using System.Windows.Forms; So, the application does not
recognize the MessageBox. Please advice. Thanks!
 
By default, Console apps do not reference System.Windows.Forms, which is
where the MessageBox.Show method lives. You can add the reference so
you can use MessageBox.Show, but I'm not sure if there are downsides to
doing that...

--Brian
 
Hi,
Welcome to MSDN Newsgroup!

If we want to pop up messagebox in console app, we should add the reference
to System.Windows.Forms.dll. You could refer to the following code and I
hope it's useful for you,

using System;

namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
System.Windows.Forms.MessageBox.Show("Hello World");
}
}
}

If there is any question, please feel free to join the community and we are
here to support you at your convenience. Thanks again and have a nice day.

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi,

I am glad to know that the problem is resolved now. It's really been a
pleasure working with
you.

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top