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

标签 c# .net 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)
   { }
}

不幸的是,此代码的编译返回错误(两次,对于每个 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?)    

如何处理这个错误?

最佳答案

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

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

关于c# - 命名空间 'Forms' 中不存在类型或命名空间名称 'System.Windows',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40891243/

相关文章:

c# - 异步 WCF 方法 WebOperationContext 在等待后为 null

c# - 为什么 DynamicObject 类中的方法不是通用的?

c# - 在没有公共(public)构造函数的情况下实例化 .NET 类

c++ - Visual Studio 2015 中的预编译 header 错误

arrays - Xamarin Studio 6.0 F#Array.tai​​l产生编译错误

c# - fatal error LNK1104 : cannot open file 'libboost_thread-vc90-mt-1_35.lib'

c# - Visual Studio Code 分析——微软自己照做吗?

C# 数据表如何对相似的行进行分组

.net - FlowLayoutPanel - 控件的自动宽度?

.net - 从表创建导航/关联以在 EF 4.0 中查看