【问题标题】:Reference FrameworkAssembly in netcoreapp1.0参考 netcoreapp1.0 中的 FrameworkAssembly
【发布时间】:2016-05-20 09:21:37
【问题描述】:

在仅运行 Windows 的 netcoreapp 上引用完整框架程序集(如 System.DirectoryServices.AccountManagement)的首选方法是什么?

dnx 支持这种方式:

 "frameworks": {
    "dnx451": {
      "frameworkAssemblies": {
        "System.DirectoryServices.AccountManagement": "4.0.0.0",
        "System.Messaging": "4.0.0.0",
        "System.Runtime.Serialization": "4.0.0.0"
      }
    }
  },

使用 netcore 将其更改为:

 "dependencies": {
    "NETStandard.Library": "1.5.0-rc2-24027"
  },

  "frameworks": {
    "netstandard1.5": {
      "imports": "dnxcore50"
    }
  }

【问题讨论】:

  • 您从事什么样的应用程序?对于类库,您只需使用正确的绰号 github.com/lextm/sharpsnmplib/blob/netcore5/SharpSnmpLib/…
  • 感谢@LexLi,它非常适合类库。但是,我无法从 WebApplication 中引用它:“不支持以下项目作为引用:- ClassLibrary2 的目标框架与当前项目 WebApplication12 中的目标不兼容。WebApplication12: .NETCoreApp,Version=v1.0 ClassLibrary2: 。 NETFramework,Version=v4.6.1"

标签: c# .net-core


【解决方案1】:

使用frameworkAssemblies 对我仍然有效。

如果您想直接从您的 ASP.NET Core 应用程序中使用该程序集,那么 project.json 将如下所示:

"dependencies": {
  "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
  "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final"
},

"frameworks": {
  "net461": {
    "frameworkAssemblies": {
      "System.DirectoryServices.AccountManagement": "4.0.0.0"
    }
  }
},

如果你想通过类库间接实现,那么类库中的 project.json 应该是这样的:

"dependencies": {
  "NETStandard.Library": "1.5.0-rc2-24027"
},

"frameworks": {
  "net461": {
    "frameworkAssemblies": {
      "System.DirectoryServices.AccountManagement": "4.0.0.0"
    }
  }
}

而在应用程序中(假设类库被称为ClassLibrary):

"dependencies": {
  "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
  "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
  "ClassLibrary": "1.0.0-*"
},

"frameworks": {
  "net461": {}
},

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    • 1970-01-01
    • 1970-01-01
    • 2018-02-13
    相关资源
    最近更新 更多