Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Visual studio unable to find namespaces

Discussion in 'Editor & General Support' started by kiwiboys, Aug 5, 2022.

  1. kiwiboys


    Oct 6, 2013
    Hello everyone,

    I've been having issues with Unity and Visual studio for the past week and have now run out of ideas on how to fix this issue, As the title states Visual Studio is unable to find namespaces of some packages e.g UnityEngine.UI and TMPro along with some assets downloaded from the Unity asset store. The thing is it complies fine with no errors in the Unity editor console, I can still work but the visual studio has a red line under any of the troublesome namespaces, It's not isolated to one project either I started a new project and straight off the bat hit the same issue with UnityEngine.UI unable to be found.

    Visual Studio not acting nicely.png

    Below I'll list the attempts that I tried to fix this

    - Restart both Visual Studio and Unity
    - restart the PC
    - Regenerate Project files
    - Remove all.Cprog and .sln files and then try Regenerate Project files
    - Reinstall Unity
    - Reinstall Visual studio plus the Required Unity packages
    - Update Unity to latest 2021.3.6f1
    - Update Visual Studio to the latest 2022(17.2.32630)
    - Move the project to a new folder
    - Rebuild The Libary folder
    - Start a new project

    So far none of the above solutions have worked for me, This only started happening after a git merge error and reverting the project to head (the last stable version of the project that was pushed to git)
    Although that doesn't explain why this is happening on a new project.
  2. Kurt-Dekker


    Mar 16, 2013
    Sounds like you've covered it all, but just in case:

    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.

    Barring all that, move on to other ideas:

    Also, try update the VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

    Also, this:
  3. kiwiboys


    Oct 6, 2013
    Unfortunately, I was unable to find a solution It's likely some setting somewhere has been corrupted or even a registry file has bugged out or something, I ended up just switching to Jetbrains rider everything working nicely in that.