簡體   English   中英

為什么我的PCL無法使用System.Runtime?

[英]Why can't my PCL use System.Runtime?

我有一個針對以下平台的PCL:

  • .NET Framework 4.5
  • Windows 8
  • Windows Phone 8.1

我需要添加對System.Runtime的引用,因為我想使用依賴於它的另一個包。 從我可以看到, 版本4.0.0似乎包含上述目標平台。 但是,當我嘗試通過NuGet安裝它時,會得到以下堆棧跟蹤:

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:\Users\James\Documents\Visual Studio 2015\Projects\PclDummy\packages'
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支持的所有平台,為什么會發生這種情況?

定位到'.NETPortable,Version = v4.5,Profile = Profile111'

確保區分參考程序集和運行時程序集。 要編譯您的PCL項目,您只需要參考程序集。 並且您已經有一個System.Runtime,它位於計算機上的C:\\ Program Files(x86)\\ Reference Assemblies \\ Microsoft \\ Framework.NETPortable \\ v4.5 \\ Profile \\ Profile111目錄中。 它已在您的項目中引用,因此該軟件包已被正確拒絕。

這些瘋狂的“但每個人都已經有了” Nuget軟件包來自CoreCLR項目。 目前,它正在迅速發展,發布的Beta版本的速度非常快。 這是Profile111支持的目標之一,它支持ASP.NET Core 5.0目標。 您的問題中沒有一個人列出,因此您可能根本不需要它。 但是,如果您願意的話,那就是項目下載此Nuget軟件包。 這是完全自動的,您無需明確要求軟件包。

只是停止嘗試安裝它。

似乎在版本4.5中不完全支持System.Runtime。

您可以在以下路徑的配置文件文件夾中檢查它:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile111

有支持的程序集和名稱空間的列表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM