System.Windows.MessageBox vs System.Windows.Forms.MessageBox

MisterXero picture MisterXero · Jan 11, 2011 · Viewed 13.3k times · Source

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?

Answer

Reed Copsey picture Reed Copsey · Jan 11, 2011

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 use System.Windows.MessageBox.