Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using .NET Standard 2.1 with UWP

I made the big mistake of taking some NuGet library updates today. It forced me to either roll back a week's worth of work or upgrade to ASP .NET Core 3.0. I hate to use stuff that's not production, but I didn't want to untangle the libraries either, so I upgraded. Then it forces me to retarget .NET Standard 2.1 libraries. Which I did. My problem now is with the client UWP code. When I try to compile, I get:

error : Project '..\ClassLibrary1\ClassLibrary1.csproj' targets 'netstandard2.1'. It cannot be referenced by a project that targets 'UAP, Version=v10.0.10586'.

This happens even with a virgin UWP and .NET Standard 2.1 library. Any clues on how to make Visual Studio 2019 client code work with the latest upgrade?

like image 461
Quarkly Avatar asked Sep 23 '19 20:09

Quarkly


People also ask

What version of .NET does UWP use?

NET Standard is supported on UWP. The . NET Standard documentation provides information on which .

Is .NET standard 2.1 compatible with .NET framework?

NET Framework doesn't support . NET Standard 2.1.

Does .NET core support UWP?

UWP does NOT run on the . NET Core App runtime like a . NET Console does, if that makes sense.

Is Microsoft getting rid of UWP?

Going forward, UWP will only receive “bug, reliability, and security fixes,” and not new features, Microsoft says, indicating that it is now deprecated. Developers with UWP apps in the market who “are happy with [the] current functionality in UWP” can of course continue to keep using UWP.


1 Answers

All Windows 10 SDKs currently don't support .NET Standard 2.1.

Windows 10 19H2 is using the same SDK number as 19H1, so it is unlikely that it will support .NET Standard 2.1. (But I certainly hope it does.)

Microsoft hasn't made an official announcement, but Windows 10 20H1 is getting a meaningful SDK update, so it is likely that it will support it. And once that's the case, UWP apps will require 20H1 to run (so that will become the minimum supported version).

One of the big issue with this situation is that Entity Framework Core 3.0 requires .NET Standard 2.1, so it can't be used in UWP apps for now (Update: This issue is resolved with Entity Framework Core 3.1 supporting .NET Standard 2.0).

By the way, as an experiment, I was able to fork Entity Framework Core 3.0 (for SQLite) and make it compile on .NET Standard 2.0. I basically had to manually copy a few new APIs from .NET Core 3.0 (like IAsyncXXX). And it worked, so it is an option for people who really need it. Note that, I did not try it with the SQL Server provider.

Update: The UWP team is planning to enable UWP apps to use .NET 5 and that's when UWP will support .NET Standard 2.1 (and more). This could happen in 20H2 or 21H1.

like image 141
user12115040 Avatar answered Oct 01 '22 18:10

user12115040