【问题标题】:The type or namespace name 'Forms' does not exist in the namespace 'System.Windows'命名空间“System.Windows”中不存在类型或命名空间名称“Forms”
【发布时间】:2022-01-11 06:23:21
【问题描述】:

我需要选择json文件。

public void LoadChartData()
{
   var ofDialog = new System.Windows.Forms.OpenFileDialog { Filter = @"json (*.json)|*.json" };
   if (ofDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
   { }
}

不幸的是,此代码的编译返回错误(两次,每个 System.Windows.Forms ):

Error   CS0234  The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)    

如何处理这个错误?

【问题讨论】:

    标签: c# .net compiler-errors .net-4.5.2


    【解决方案1】:

    在您的项目中包含System.Windows.Forms 程序集(如错误消息建议的那样)。

    转到您的解决方案资源管理器,右键单击您的项目。然后单击添加参考。选择System.Windows.Forms并点击OK

    【讨论】:

      猜你喜欢
      • 2014-03-04
      • 2016-02-11
      • 1970-01-01
      • 2016-07-26
      • 1970-01-01
      • 2022-07-07
      • 1970-01-01
      相关资源
      最近更新 更多