我已经创建了.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().