简体   繁体   English

具有NET标准2.0的引用项目的UWP(UAP 10.0.16299)出现LINQ(IEnumerable)问题

[英]UWP (UAP 10.0.16299) with referenced project with .Net standard 2.0 occurs problem with LINQ (IEnumerable)

I face a problem with my UWP application. 我的UWP应用程序遇到问题。 I have the client UWP (target version is Windows 10 Fall Creator Update 10.0.16299 and same for min version ) which reference 2 other projects Net standard 2.0 我有客户端UWP(目标版本是Windows 10 Fall Creator Update 10.0.16299,最小版本相同),它引用了2个其他项目Net standard 2.0

I get those errors in AppShell.cs and some other Page : 我在AppShell.cs和其他一些Page中收到这些错误:

Severity Code Description Project File Line Suppression State Error CS0012 The type 'IEnumerable<>' is defined in an assembly that is not referenced. 严重性代码说明项目文件行抑制状态错误CS0012在未引用的程序集中定义了类型“ IEnumerable <>”。 You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 您必须添加对程序集“ netstandard,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51”的引用。

the lines where are the problem are all about link : 问题所在的行都是关于link的:

var item = (from p in PrimaryMenuItems where p.DestPage == e.SourcePageType select p).SingleOrDefault();

I really don't understand why. 我真的不明白为什么。

It might be that NuGet Packages were not correctly restored. 可能是NuGet软件包未正确还原。 Close Visual Studio and delete all bin and obj folders in your solution. 关闭Visual Studio,然后删除解决方案中的所有binobj文件夹。 Then open your solution again and right-click on the solution in Solution Explorer and select Restore NuGet Packages . 然后再次打开您的解决方案,然后在解决方案资源管理器中右键单击该解决方案,然后选择Restore NuGet Packages The errors should go away after that. 之后错误应消失。

Finally after many hours, I just understood and found the solution to this tricky issue. 终于,几个小时后,我才了解并找到了解决这个棘手问题的方法。 In my UWP project file (.csproj) , the version of the referenced Microsoft.NETCore.UniversalWindowsPlatform was 5.3.3, I replaced it by 6.1.5 and it works. 在我的UWP项目文件(.csproj)中,所引用的Microsoft.NETCore.UniversalWindowsPlatform的版本为5.3.3,我将其替换为6.1.5,并且可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM