屏幕类不会被Visual Studio 2017识别

时间:2018-06-18 06:50:13

标签: c#

当我尝试使用屏幕类时,我遇到Visual Studio 2017的问题:

错误CS0246类型或命名空间名称'屏幕'找不到(你错过了使用指令或汇编引用吗?

错误CS0234类型或命名空间名称' Forms'命名空间中不存在System.Windows' (你错过了一个程序集引用吗?)

https://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx

@JsonSubtype

2 个答案:

答案 0 :(得分:2)

这里的主要问题是你在控制台应用程序中,并调用winforms库。

Screen.AllScreens Property

  

获取系统上所有显示的数组。

     
      
  • 命名空间:System.Windows.Forms
  •   
  • 程序集:System.Windows.Forms(在System.Windows.Forms.dll中)
  •   

以上是非常重要的

如果遇到这样的问题,请尝试在线查看文档

说什么,是否需要将程序集System.Windows.Forms添加到您的应用程序中。

How to: Add or Remove References By Using the Add Reference Dialog Box

  

在Visual C#中添加引用

     
      
  • 在Solution Explorer中,右键单击项目节点,然后单击Add Reference。

  •   
  • 在“添加引用”对话框中,选择指示要引用的组件类型的选项卡。

  •   
  • 选择要引用的组件,然后单击“确定”。

  •   

答案 1 :(得分:0)

您似乎没有引用System.Windows.Forms库。

  1. 转到Project菜单
  2. 选择Add reference
  3. 点击Assemblies(左侧)
  4. 检查System.Windows.Forms
  5. 点击确定
  6. 当然这只适用于.NET Framework项目,所以如果你的工作没有成功(System.Windows.Forms不能工作)。

相关问题