Search code examples
c#.netwpfwinformsmessagebox

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


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?


Solution

  • 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.