c# - 创建 PCL NET 4.0 在 Visual Studio 2015 中出现错误

标签 c# portable-class-library

我使用的是 VS 2015 Pro。如果我创建一个新项目类库(可移植)定位: 网络框架 4.0 window 8

一切正常。

但是当我添加到定位时: Windows Phone 8.1

出现如下两个错误:

There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll", "x86". This mismatch may cause runtime failures.

并且未找到 Linq:

The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

(PS。我确信在我让 Visual Studio 2015 更新一些扩展之前一切正常)

注意如果我以 x86 为目标,第一个错误消失,但第二个错误仍然存​​在。

1) Windows Phone 8 和
Visual Studio 在哪里加载 Windows Phone 8 程序集?

2) 如何恢复 Windows Phone 8 程序集? enter image description here

编辑

Project references

EDIT2

重要 如果我更改目标并选择 NET 4.0.3,项目编译正常!

project compiles with Phone 8.1 and NET 4.0.3

EDIT3 重要 我发现它与 NET 可移植框架配置文件有关,存储在: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable

(链接 framework profiles

为我的项目使用包管理器控制台: PM> $p.Properties.Item("TargetFrameworkMoniker").Value .NETPortable,Version=v4.0,Profile=Profile328

在 Profile328 的文件夹中,我注意到 .dll 中没有 但只有 .xml 文件......发生了什么事?!怎么恢复?!

最佳答案

当你拥有可移植类库时,你会遇到这样的情况: 如果需要,在 .NET 程序集中有所有库。

尝试删除项目并创建新的可移植类库

enter image description here


enter image description here


enter image description here

关于c# - 创建 PCL NET 4.0 在 Visual Studio 2015 中出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33865936/

相关文章:

nuget - 我可以使用 DNX/DNU 构建 "old school"PCL 吗?

sqlite - 将 sqlite.net "bigint"替换为自动增量主键约束的整数

visual-studio - Xamarin 和 Visual Studio、Windows Phone 和 ASP.NET : Is a true single class library possible?

c# - Silverlight4 + C# : Using INotifyPropertyChanged in a UserControl to notify another UserControl is not notifying

c# - 收集没有重复但有顺序,快速包含检查和添加/删除

c# - 基于其他值的自定义验证

wpf - 命名空间中不存在名称 ViewModelLocator

c# - Xamarin Forms - Java.Interop.lz4 访问被拒绝错误

c# - Newtonsoft JSON.NET 解析为自定义键/值对对象数组

c# - 如何让 MVVM Light Messenger 与 PCL 配合使用