C# MessageBox.Show報錯,無法識別函數

使用 MessageBox.Show 需要引入 using System.Windows.Forms;

引入  using System.Windows.Forms; 再次報錯:

  • 錯誤 命名空間“System”中不存在類型或命名空間名稱“Windows”。是否缺少程序集引用?

【解決過程】

此錯誤原因是缺少了對應的dll庫System.Windows.Forms.dll,即需要添加對System.Windows.Forms.dll庫的引用。

方法是:

右擊項目名下面的那個“引用” -> 添加引用 –> .NET –> 在“組建名稱”中找到”System.Windows.Forms”並添加。

即可解決此問題。

ini_path += "\\Project.ini";
if (!File.Exists(ini_path))
{
    System.Windows.Forms.MessageBox.Show("Project.ini文件不存在:"+ini_path, (String)rm.GetObject("Message_Error"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章