命名空间'System.Windows'中不存在类型或命名空间名称'Forms'

Jar*_*lak 2 .net c# compiler-errors .net-4.5.2

我需要选择json文件.

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

不幸的是,编译此代码会返回错误(每次两次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?)    
Run Code Online (Sandbox Code Playgroud)

如何处理这个错误?

Pat*_*man 6

System.Windows.Forms程序中包含程序集(如建议的错误消息).

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