【问题标题】:Mscorlib not referenced in Asp.Net 5 Class LibraryAsp.Net 5 类库中未引用 Mscorlib
【发布时间】:2015-04-14 19:26:47
【问题描述】:

我正在尝试将库移植到 ASP.NET CORE,但我很难让 Visual Studio 引用所有重要部分。我注意到 mscorlib 仅添加到 ASP.NET 5.0 下的引用中,而不是 ASP.NET CORE 下的引用。在这两个框架下,即使在 ASP.NET 5.0 下引用 mscorelib,我也没有得到像 System.Object 这样的基本类型

一开始我使用 beta2,但后来我构建了自己的 CoreCLR 并使用 kvm 将其安装在我的机器上。

Kvm 列表显示如下:

Active Version           Runtime Architecture Location                      Alias
------ -------           ------- ------------ --------                      -----
       1.0.0-beta4-11037 clr     x64          C:\Users\SomeName\.k\runtimes
       1.0.0-beta4-11037 clr     x86          C:\Users\SomeName\.k\runtimes
  *    1.0.0-beta4-11037 coreclr x64          C:\Users\SomeName\.k\runtimes default
       1.0.0-beta4-11037 coreclr x86          C:\Users\SomeName\.k\runtimes

当我尝试在 Visual Studio 中调试我的项目时,它仅适用于 beta2,但不适用于我的自定义构建。所以我必须手动运行我的项目:

k run -r CoreCLR -X64

一切运行良好。

我可以通过将调试器附加到 Visual Studio 中来调试正在运行的项目,但这不是一个好的体验。当然这是测试状态,但也许我的设置有问题,有人可以帮助我。

项目.json

{
"version": "1.0.0-*",
"dependencies": {
     "Microsoft.Framework.ConfigurationModel": "1.0.0-beta4-1083",
    "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4-10837",
    "Microsoft.Framework.ConfigurationModel.Xml": "1.0.0-beta4-10837",
    "System.Collections": "4.0.10-beta-22613",
    "System.Collections.Concurrent": "4.0.10-beta-22613",
    "System.Collections.NonGeneric": "4.0.0-beta-22613",
    "System.Collections.Specialized": "4.0.0-beta-22613",
    "System.ComponentModel": "4.0.0-beta-22613",
    "System.ComponentModel.Annotations": "4.0.10-beta-22613",
    "System.ComponentModel.EventBasedAsync": "4.0.10-beta-22613",
    "System.ComponentModel.TypeConverter": "4.0.0-beta-22613",
    "System.Diagnostics.Tools": "4.0.0-beta-22613",
    "System.Diagnostics.TraceSource": "4.0.0-beta-22613",
    "System.Dynamic.Runtime": "4.0.10-beta-22613",
    "System.Linq": "4.0.0-beta-22613",
    "System.Linq.Expressions": "4.0.0-beta-22613",
    "System.ObjectModel": "4.0.10-beta-22613",
    "System.Reflection": "4.0.10-beta-22613",
    "System.Reflection.Emit.ILGeneration": "4.0.0-beta-22613",
    "System.Reflection.Extensions": "4.0.0-beta-22613",
    "System.Reflection.Primitives": "4.0.0-beta-22613",
    "System.Reflection.TypeExtensions": "4.0.0-beta-22613",
    "System.Runtime": "4.0.20-beta-22613",
    "System.Runtime.Extensions": "4.0.10-beta-22613",
    "System.Runtime.Serialization.Json": "4.0.0-beta-22613",
    "System.Runtime.Serialization.Primitives": "4.0.0-beta-22613",
    "System.Runtime.Serialization.Xml": "4.0.10-beta-22613",
    "System.Security.AccessControl": "4.0.0-beta-22613",
    "System.Security.Claims": "4.0.0-beta-22613",
    "System.Security.Principal": "4.0.0-beta-22613",
    "System.Security.Principal.Windows": "4.0.0-beta-22613",
    "System.Text.RegularExpressions": "4.0.10-beta-22613",
    "System.Threading": "4.0.10-beta-22613",
    "System.Threading.AccessControl": "4.0.0-beta-22613",
    "System.Threading.Tasks": "4.0.10-beta-22613",
    "System.Threading.Thread": "4.0.0-beta-22613",
    "System.Threading.ThreadPool": "4.0.10-beta-22613"
},
"frameworks": {
     "aspnet50": {
        "dependencies": {
        }
    },
    "aspnetcore50": {
        "dependencies": {
        }
    }
}

更新 我注意到 Visual Studio 没有加载正确的包,即使它显示刷新,所以我更新了这样的所有内容:

kpm restore

这大大改善了一切。但我仍然无法在 Visual Studio 中正确运行它,因为加载 System.Threading 时出现类型加载异常。 手动运行它仍然没有问题。

看来我得等到下一个版本的 Visual Studio 出来才能获得更好的体验。

我很想知道我从哪里获得 System.Runtime 的源代码以检查 ASPNETCORE50 中实现的内容。

【问题讨论】:

  • Mscorlib 仅存在于桌面 CLR (aspnet50)。在 CoreCLR (aspnetcore50) 中,它被拆分为许多小包,如 System.RuntimeSystem.Threading。 “仅适用于 beta2 但不适用于我的自定义版本”是什么意思?你有错误吗?
  • 如果我有任何错误,请回答您的问题。 Visual Studio 告诉我在使用它之前我必须先安装我的运行时版本。但是当它没有安装时,为什么我可以将它与 k run 一起使用就可以了?如果有帮助,我正在使用 kvm 的开发版本。
  • 啊...在Beta2和Beta4之间,文件夹结构发生了变化。 VS 的公共版本不了解最新的运行时。抱歉,在更新的 VS 工具出现之前,您无能为力。如果您使用 VS,请暂时使用 Beta2。
  • 非常感谢,现在我明白 Visual Studio 抱怨的原因了。
  • @VictorHurdugaci 你想发布这个作为答案吗?

标签: c# asp.net-core visual-studio-2015 .net-core


【解决方案1】:

在 Beta2 和 Beta4 之间,文件夹结构发生了变化。 VS 的公共版本不了解最新的运行时。抱歉,在更新的 VS 工具出现之前,您无能为力。如果您使用 VS,请暂时继续使用 Beta2。

【讨论】:

    猜你喜欢
    • 2016-12-03
    • 1970-01-01
    • 2016-04-22
    • 1970-01-01
    • 2016-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    相关资源
    最近更新 更多