加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-14 04:18:47 所属栏目:Windows 来源:网络整理
导读:我已经创建了.NET Core类库并尝试针对net40框架构建它.我想从System. Windows.Forms程序集中使用Clipboard类.我怎样才能做到这一点? 我的project.json文件: { "version": "1.0.0-*","dependencies": { "NETStandard.Library": "1.6.0" },"frameworks": { "
我已经创建了.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().

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读