如何在.NET Core类库中使用System.Windows.Forms

前端之家收集整理的这篇文章主要介绍了如何在.NET Core类库中使用System.Windows.Forms前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经创建了.NET Core类库并尝试针对net40框架构建它.我想从System. Windows.Forms程序集中使用Clipboard类.我怎样才能做到这一点?

我的project.json文件

{
    "version": "1.0.0-*","dependencies": {
        "NETStandard.Library": "1.6.0"
    },"frameworks": {
        "netstandard1.6": {
            "imports": "dnxcore50","buildOptions": {
                "define": [
                    "NETCORE"
                ]
            },"dependencies": {
                "System.Threading": "4.0.11","System.Threading.Thread": "4.0.0","System.Threading.Tasks":  "4.0.11"
                }
        },"net40": {
            "buildOptions": {
                "define": [
                    "NET40"
                    ]
                },"dependencies": {
                // dependency should be here but there is no such dll
            }
        }
    }
}

我所有的net40特定代码都在NET40下定义.有什么想法吗?

你需要的是 "frameworkAssemblies",例如:
"frameworks": {
  "netstandard1.6": {
    "dependencies": {
      "NETStandard.Library": "1.6.0"
    }
  },"net40": {
    "frameworkAssemblies": {
      "System.Windows.Forms": {}
    }
  }
}

使用剪贴板还需要将主线程设置为STA,因此不要忘记在应用程序中将[STAThread]添加到Main().

原文链接:https://www.f2er.com/netcore/364715.html

猜你在找的.NET Core相关文章