为什么我的 PCL 不能使用 System.Runtime? [英] Why can't my PCL use System.Runtime?

查看:22
本文介绍了为什么我的 PCL 不能使用 System.Runtime?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对以下平台的 PCL:

I have a PCL that targets the following platforms:

  • .NET 框架 4.5
  • Windows 8
  • Windows Phone 8.1

我需要添加对 System.Runtime 因为我想使用另一个依赖它的包.据我所知,version 4.0.0 似乎包含目标上面提到的平台.但是,当我尝试通过 NuGet 安装它时,我得到了这个堆栈跟踪:

I need to add a reference to System.Runtime because I want to use another package that depends on it. From what I can see, version 4.0.0 appears to include the target platforms mentioned above. However, when I try installing it via NuGet, I get this stack trace:

PM> Install-Package System.Runtime -Version 4.0.0
# ...
Install failed. Rolling back...
Package 'System.Runtime 4.0.0' does not exist in project 'PclDummy'
Package 'System.Runtime 4.0.0' does not exist in folder 'C:UsersJamesDocumentsVisual Studio 2015ProjectsPclDummypackages'
Install-Package : Could not install package 'System.Runtime 4.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not 
contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

如果 System.Runtime 支持我的 PCL 支持的所有平台,为什么会发生这种情况?

Why does this happen if System.Runtime supports all of the platforms my PCL does?

推荐答案

针对'.NETPortable,Version=v4.5,Profile=Profile111'

that targets '.NETPortable,Version=v4.5,Profile=Profile111'

一定要区分引用程序集和运行时程序集.要编译您的 PCL 项目,您只需要引用程序集.您已经有一个 System.Runtime,它位于您机器上的 C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETPortablev4.5ProfileProfile111 目录中.它已在您的项目中被引用,因此该包被正确拒绝.

Be sure to distinguish between reference assemblies and runtime assemblies. To get your PCL project compiled, you only need reference assemblies. And you already have one for System.Runtime, it is located in the C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETPortablev4.5ProfileProfile111 directory on your machine. It is already referenced in your project so the package was correctly rejected.

这些疯狂的但每个人都已经有了这个"Nuget 包来自 CoreCLR 项目.它现在正在迅速发展,测试版以非常高的速度发布.这是 Profile111 支持的目标之一,它支持 ASP.NET Core 5.0 目标.不是您在问题中列出的,因此您可能根本不需要它.但是如果你愿意,那么下载这个 Nuget 包的就是那个项目.这是完全自动的,您不会明确要求包.

These kind of crazy "but everybody already has this" Nuget packages come from the CoreCLR project. It is evolving rapidly right now with beta versions released at a very high rate. Which is one of the targets supported by Profile111, it supports an ASP.NET Core 5.0 target. Not one you listed in your question so you probably don't need it at all. But if you would then it would be that project that downloads this Nuget package. Which is entirely automatic, you don't ask for the packages explicitly.

停止尝试安装它.

这篇关于为什么我的 PCL 不能使用 System.Runtime?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆