Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

c# - Visual Studio 2019 Not Showing .NET 5 Framework

I've been trying to upgrade my ASP.NET project in Visual Studio from the .NET 4.7.2 framework to .NET 5. I can't figure out what the problem is, because I've tried several different things and none of them have made .NET 5 available.

  1. I've installed the latest version of Visual Studio Community 2019, version 16.8.4.
  2. I've installed .NET 5.0.102. The Command Prompt confirms this when I type dotnet --version.
  3. In Visual Studio's Tools > Options > Environment > Preview Features, I've enabled "Use previews of the .NET Core SDK", and restarted the program.
  4. In Visual Studio Installer, I've selected Modify > Individual components. The .NET 5.0 Runtime is installed, but there's nothing listed for a .NET Framework 5; the highest listed is 4.8.
  5. I've tried restarting the program and my computer, and reinstalling both Visual Studio and the .NET 5.0.102 framework.

The About window in Visual Studio says that my .NET version is 4.8.040. The most recent .NET framework that I can select in my project is 4.7.2. Creating a new project doesn't offer a newer version either.

I want to work with C# 9.0, but my project is stuck in 7.3. Any idea what I'm doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

.NET 5 is not a direct replacement for .NET Framework 4.5+. If you try to create a new project and choose .NET Framework, then you will be able to choose for example 4.7, 4.8, but not .NET 5.

You will only find .NET 5 in projects which are .NET Core type.

In summary - you can't switch .NET Framework project to .NET 5 using simple Project Property window. You have to rewrite the application to .NET 5 - which is indeed the next version after .NET Core 3.1.

Regarding your question:

I want to work with C# 9.0, but my project is stuck in 7.3. Any idea what I'm doing wrong?

Please look at the C# language versions page. C# 8.0 is available for netstandard2.1 which is not supported by .NET Framework. Same thing with C# 9.0.

What is .NET 5 in comparison to .NET Core and .NET Framework you can read on Microsoft Dev Blog.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...