Using System.windows.forms In .net 6

0 views
Skip to first unread message

Breanna Mangels

unread,
Aug 4, 2024, 1:46:19 PM8/4/24
to segbetyperp
Ihave started learning Vb.net. I am using Visual Studio Express 2012.

While making a console application, when I write "System.Windows.Forms" to use message box, then compiler gives an error: Class " System.Windows.Forms" is not defined. My compiler only supports two methods of this class

1-)Systems.Windows.Markup

2-) Systems.Windows.Input


A library project doesn't reference System.Windows.Forms by default either, but it's very common to define form components in a DLL. I'm not convinced the default references are a good argument for what you should and shouldn't use in a particular project type.


Console applications are somewhat rare relative to Forms, WPF, and library projects. However, it's not as uncommon as you might think to mix console and GUI stuff. A more realistic example than MessageBox would be OpenFileDialog or a custom form in a test project.


I can think of one good reason why you would want to use a messagebox in a console application. If you have an operation that runs for a long enough time that you don't want to watch it but you need to be notified as soon as it completes, you might want to pop up a notification in a messagebox. True, you could always BEEP, but you might want a notification that works even if the volume is muted.

3a8082e126
Reply all
Reply to author
Forward
0 new messages