C# MessageBox缺少程序集

C# MessageBox缺少程序集,c#,winforms,C#,Winforms,我正在使用System.Windows.Forms.MessageBox; 我还在VS中添加了所需的参考 为什么在系统中找不到缺少的程序集。此行中存在Windows错误 System.Windows.MessageBox.Show("An error occured: " + error.Problem); 因为您想使用System.Windows.Forms类中的MessageBox,但只编写了System.Window。 将代码更改为 System.Windows.Forms.Messag

我正在使用System.Windows.Forms.MessageBox; 我还在VS中添加了所需的参考

为什么在系统中找不到缺少的程序集。此行中存在Windows错误

System.Windows.MessageBox.Show("An error occured: " + error.Problem);

因为您想使用System.Windows.Forms类中的MessageBox,但只编写了System.Window。 将代码更改为

System.Windows.Forms.MessageBox.ShowAn发生错误:+错误。问题

它会工作。

适用于WPF应用程序。你需要

因此,您的代码应该是:

System.Windows.Forms.MessageBox.Show("An error occured: " + error.Problem);
或者,您可以包含一个using语句:

using System.Windows.Forms;
然后使用:

MessageBox.Show("An error occured: " + error.Problem);

它的System.Windows.Forms.MessageBox不是System.Windows.MessageBox我以前尝试过你的第二个解决方案,但似乎不起作用_@鲁比,你有什么错误吗?您是否将using指令与其他using指令一起放在类的顶部?