c# - 无法添加对 ´ 的引用。程序集必须具有 dll 或 exe 扩展名才能被引用

标签 c# .net-core

我有普通的 c# 控制台应用程序 (.NET 4.6),我想在其中引用 .NET Core 类库:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Newtonsoft.Json": "9.0.1"
  },

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

我得到以下异常:

enter image description here

最佳答案

简单的解决方案:

我的 .NET 控制台应用程序使用 .NET 4.6,并且应该引用使用 .NET Platform Standard 1.4 的核心类库。

Mapping the .NET Platform Standard to platforms表示 .NET 4.6 与 .NET Platform Standard 1.3 兼容。

将核心类库的project.json改成(节选)

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

解决了问题。

Here是一个说明问题的兼容性表(.NET 4.6 与 .NET Platform Standard <= 1.3 兼容): enter image description here

关于c# - 无法添加对 ´ 的引用。程序集必须具有 dll 或 exe 扩展名才能被引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38341147/

相关文章:

c# - 从 List<T> 中隐式删除通用参数

c# - 删除字符串特定部分的数字(括号内)

c# - 即使在注销后,ADAL for .NET for iOS 应用程序也可以对以前的用户进行身份验证

c# - 在 EF Core 中添加一对一关系时迁移数据?

c# - 如何序列化接口(interface)默认属性?

c# - Windows 8 应用程序 WebView 捕获事件目标 ="_blank"

c# - 在 Visual Studio 中移动 C# 项目的中间目录

c# - 对于 .net core 3.0 中的 wpf 项目,Xaml UI Designer 处于非事件状态

.net-core - 是否可以清除 .net core 配置中的数组?

c# - 除了相应的 `foreign key Id` 之外,我还应该定义 `navigation property` 属性吗?