我正在尝试打开一个C#解决方案,该解决方案是由Unity V2020.3.19F项目与Visual Studio 2022一起生成的。使用Visual Studio 2019打开它,效果很好,但是我有理由可以使用它打开它。 V2022(例如Github副副总片)。我在以前的Windows 10安装中没有问题。
在VS2022中打开解决方案后,我会为解决方案中的每个项目提供以下弹出提示:
”目标项目为.NET Framework 4.8并加载项目,但是整个文件都以红线出现。当悬停在带下划线的布尔属性上时,该错误显示为:`cs0518:预定义的类型'system.boolean'未定义或导入。
选择第二个选项打开此url 在我的浏览器中我要安装.NET Framework 4.7.1定位包(已通过Visual Studio Installer安装)。当我尝试安装.NET Framework 4.7.1 Runtime 时,安装程序以 .NET Framework 4.7.1或以后的更新已安装在此计算机上。
时我尝试安装.NET框架4.7.1 开发人员包,安装程序允许我从“维修”,“卸载”或“ CANCAL”中选择。维修没有效果。
我安装了Visual Studio的两个版本(2019&2022),这是Visual Studio Installer的常规方式,以及“具有Unity with Unity”工作负载的“游戏开发”,这告诉我它已经安装了所有依赖项:
这是我到目前为止尝试的:
- 卸载&通过Visual Studio安装程序
- 卸载& 重新安装视觉工作室的所有版本重新安装Unity,通过Unity Hub安装了Visual Studio模块(仅打开Visual Studio Installer供我选择我要安装的版本)
- 通过Unity Editor
- 卸载对.NET框架的任何引用
- 。重新安装.NET框架定位包4.7.1从Visual Studio Installer中或通过Microsoft SDK网站手动从提示中
手动无效。对如何使VS2022停止抱怨的任何帮助都非常感谢。
更新1:我找到了几个线程,人们建议在“编辑 - > preverences - >外部工具”中只按再生项目文件
按钮。这对我没有帮助。
更新2:i我可能会想象的一切,以不同的订单和不同的组合帮助 :(
I am trying to open a C# solution that has been generated from a Unity v2020.3.19f project with Visual Studio 2022. Opening it with Visual Studio 2019 works just fine, but there are reasons I'd like to be able to open it with v2022 (such as GitHub Copilot). I did not have issues with this on my previous install of Windows 10.
Upon opening the solution in VS2022, I get the following pop-up prompt for every project in the solution:
Choosing the first option updates the target project to .NET Framework 4.8 and loads the project, but the whole file appears with red lines. When hovering over an underlined bool Property, the error shows as: `CS0518: Predefined type 'System.Boolean' is not defined or imported.
Choosing the second option opens this URL in my browser, prompting me to install .NET Framework 4.7.1 targeting pack (which was already installed via the Visual Studio Installer). When I try to install the .NET Framework 4.7.1 runtime, the installer responds with .NET Framework 4.7.1 or a later update is already installed on this computer.
When I try to install the .NET Framework 4.7.1 Developer Pack, the installer allows me to choose from "Repair", "Uninstall", or "Cancel". Repairing has no effect.
I installed both versions of Visual Studio (2019 & 2022) the usual way through the Visual Studio Installer, along with the "Game Development with Unity" workload, which tells me it's installed all dependencies just fine:
Here's what I've tried so far:
- Uninstall & reinstall all versions of Visual Studio through the Visual Studio Installer
- Uninstall & reinstall Unity, with the Visual Studio module installed through Unity Hub (which just opens the Visual Studio Installer for me to choose which version I want to install)
- Regenerate project files through the Unity Editor
- Uninstall any references to .NET Framework through the Control Panel
- Try reinstalling .NET Framework targeting pack 4.7.1 either from the Visual Studio Installer or manually through the Microsoft SDK website from the prompt
Nothing works for me. Any help on how to make VS2022 stop complaining is greatly appreciated.
Update 1: I found a couple of threads where people suggested simply pressing the Regenerate project files
button in "Edit -> Preferences -> External Tools`. This has not helped me.
Update 2: I've tried everything I can possibly imagine, in different orders and different combinations. I even reinstalled Windows 10 to no avail. It's like Visual Studio just doesn't want to accept that the .NET Framework 4.7.1 targeting pack is installed. Please help :(
发布评论
评论(3)
检查此
https://learn.microsoft.com/en-us/aswers/questions/733018/visual-studio-2022-cannot-locate-locate-intald-net-net-fra.html
如果您修改了ProgramFilesDir的价值(x86),只是将其修改回C:\ programFiles(x86)可以解决问题
check this
https://learn.microsoft.com/en-us/answers/questions/733018/visual-studio-2022-cannot-locate-installed-net-fra.html
If you modified the value of ProgramFilesDir(x86), just to modify it back to C:\ProgramFiles(x86) can solve the problem
这是一个非常有趣的问题,我首先尝试的主要解决方案是确保您甚至在构建解决方案之前就针对正确的.NET框架。您使用的是.NET 4.X,需要以Unity进入配置设置和播放器设置,并确保其在不同版本上不在其他版本上,对我来说,Unity仍然默认为.NET Standard 2.0。按照位置的步骤在这里。这样做。
另一个解决方案是查看第一个选项是否真的给您带来了阻止您使用Unity的错误,因为我知道Visual Studio代码偶尔会在告诉我我错的地方有问题,我的程序是错误的,我做出的每个人的选择都很差而且我很穷,但是在团结方面,游戏机中没有出现错误,我可以打出没有问题。在这种情况下,我只需要重建几次,并摆弄VS代码,直到Omnisharp停止对我大喊大叫。
显然,我的情况与您遇到错误“
”,因为研究了它,我已经单击了一些链接,尝试如果该错误仍然存在。如果您无法阻止错误开始,我建议您尝试从选项One修复升级的版本,因为这很可能会让您最接近解决方案。
That is a very interesting problem, my main solution for you to first try is to make sure you are even targeting the correct .net framework in UNITY before you even build the solution. You are using the .NET 4.x, you need to go into your configuration settings and player settings in unity and ensure its not on a different version, for me, unity still defaults to .net standard 2.0. Follow the steps located here. To do so.
Another solution is to see if that first option actually gives you errors that prevent you from using unity, because I know that Visual Studio Code has problems occasionally where it tells me im wrong, my program is wrong, every life choice I have made was poor and I am poor, yet in unity, there are no errors showing in the console and I can hit play no problem. In that case I just had to rebuild a few times and fiddle with vs code until omnisharp stopped yelling at me.
Apperently I have been in a similar situation as when you were getting the error "
Predefined type 'System.Object' is not defined or imported
" because looking into it, I already have clicked on some of the links, try this one if that error persists. If you cannot prevent the errors to begin with, I would recommend you trying to fix the upgraded version from option one as that is more than likely going to get you the closest to a solution.新建一个空项目,并从vs2022生成cs项目空文件
并仅复制您的资产和项目设置
从以前损坏的项目中删除任何 vs 生成的文件并
会没事的。
这发生在我身上并且已经解决了。
create a new empty project and generate a cs project empty file from vs2022
and the copy your assets and projects settings only
remove any vs generated files from previous damaged projects and
it will be fine.
that happen to me and it's fixed.