简体   繁体   中英

How do I to fix IntelliSense in VSCode not working and OmniSharp error messages when loading unity C# scripts?

I have installed VSCode, the C# extension for VSCode, via the extensions panel. I then installed .NET 5.0 from the Microsoft website. Finally, I installed the Unity hub and Unity. Unity booted I went into the Preferences menu (a submenu within Edit) and in External Tools set the script editor to Visual Studio Code. I started following a tutorial to learn the basics, but when I created a script and opened it in VSCode I got the following error messages in the OmniSharp log:

[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, 
        install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your 
        application.
You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\richa\BrackeysTutorial\Assembly-CSharp.csproj'.
c:\Users\richa\BrackeysTutorial\Assembly-CSharp.csproj
c:\Users\richa\.vscode\extensions\ms-dotnettools.csharp-1.23.9\.omnisharp\1.37.7-
beta.23\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1180,5): Error: The reference 
assemblies for .NETFramework,Version=v4.7.1 were not found.
To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or
retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: c:\Users\richa\BrackeysTutorial\Assembly-CSharp.csproj

This result of this was that IntelliSense didn't work and I got various other errors in the log when I started typing. What is the best way to fix this problem?

I solved the problem by installing the developer pack 4.7.1 as the error message suggested from this site. I tried a couple of things before this, like changing OmniSharp settings, but that didn't work. Unfortunately, this may not work for Mac or Linux users.

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