简体   繁体   中英

The C# project is targeting NETFramework Version=v4.7.1, which is not installed on this machine

I've just downloaded Unity 2020.1.0f1 and included Visual Studio Community 2019 in the options. When I open C# files within Unity, each file I open loads on a new instance of VS2019 (instead of loading in another tab of the same instance), and shows the window below:

在此处输入图像描述

I went to Visual Studio Installer and made sure to install not only Developer Tools 4.7.1, but all existent versions (sorry for the image not in english but it's understandable):

在此处输入图像描述

The error keeps appearing everytime I open a C# file. How can I fix it?

You can install this targeting frameworks using the visual studio installer.

Visual Studio Installer -> Modify -> Individual Components -> Select the needed .NET Framework targeting pack versions

安装组件

Reference: http://dahlindevelopment.com/blog/september-2018/the-web-project-is-targeting-netframework,-version/

Visual Studio moved to Package Manager in 2020.1

I've just solved. I'll show the steps I took.


1 First, in VS2019, right click on the Project and click in Manage NuGet Packages :

在此处输入图像描述

2 Click in Browse and search for NETFramework . Look for the version that is right for you. In my case, it was this one ( Microsoft.NETFramework.ReferenceAssemblies.net471 ):

在此处输入图像描述

3 Reload the project. In my case, the boring window stopped appearing and the files are opening in new tabs of the same VS2019 instance, instead of opening a new instance of VS2019 for each file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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