I am having trouble finding out what the key differences are between the two message boxes. What is the difference between System.Windows.MessageBox
and System.Windows.Forms.MessageBox
?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
One additional point should be noted:
If you want to display a message box in an application that is neither a windows forms application or a forms application (such as a .NET console application), you should not drag in assembly references for either as seems to be the common mantra all over the internet.
Instead, you should use pinvoke and call into User32 as follows:
The both basically do the same thing, except
system.windows.messagebox
is WPF andsystem.windows.forms.messagebox
is Windows Forms. If you're using WPF use the former, for WinForms use the latter.Both eventually call the same low level windows API as far as I know...
System.Windows.MessageBox
was added with WPF, and exists within the WPF assemblies (PresentationFramework.dll).System.Windows.Forms.MessageBox
was added with Windows Forms, and exists within the Windows Forms assemblies.If your program is a Windows Forms program, I would use the latter (
System.Windows.Forms.MessageBox
), as it won't pull in a dependency on WPF. On the other hand, if you are developing for WPF, I'd useSystem.Windows.MessageBox
.