This error suddenly started appearing when I build my unity solution in visual studio. It’s not an error in Unity, just in VS 2022, and it’s preventing me from attaching the debugger because the build is failing. I build, and I see these errors.
And I go there in the script, and that line is in fact erroring out, but only in VS, not unity console. And since it’s a default unity package, I can’t (aren’t supposed to) edit the lines, so I can’t remove the error.
This may help you with intellisense and possibly other Visual Studio integration problems:
Sometimes the fix is as simple as doing Assets → Open C# Project from Unity. Other times it requires more.
Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.
None of these work, I don’t think this is a VS issue but a project issue. Multiple people are working on this project, not a single one of them is able to get the debugger to work anymore.
It’s like scripts in certain assemblies can’t be attached to
I was having the exact same issue. This fix worked for me: Close Visual Studio, then in Unity under File → Build Settings, check the Development Build box, then under Assets click “Open C# Project”.