我有简单的c#控制台应用程序(.NET 4.6),我想引用.NET核心类库:
- {
- "version": "1.0.0-*","dependencies": {
- "NETStandard.Library": "1.6.0","Newtonsoft.Json": "9.0.1"
- },"frameworks": {
- "netstandard1.4": {
- "imports": "dnxcore50"
- }
- }
- }
我得到以下例外:
解决方法
简单解决方案:
我的.NET控制台应用程序使用.NET 4.6,并应使用.NET Platform Standard 1.4引用核心类库.
Mapping the .NET Platform Standard to platforms说.NET 4.6与.NET Platform Standard 1.3兼容.
将Core Class Library的project.json更改为(摘录)
- "frameworks": {
- "netstandard1.3": {
- "imports": "dnxcore50"
- }
- }
解决问题.
Here是一个演示问题的兼容性表(.NET 4.6与.NET Platform Standard <= 1.3)兼容):