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

Question Visual Studio doesn't recognize namespaces anymore

Discussion in 'Editor & General Support' started by VincentAbert, Oct 18, 2020.

  1. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    120
    Hello !

    Today, as I opened my project, I noticed that I had about 1K error in Visual Studios. Basically anything other than
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    is throwing an error : The type or namespace name 'FirstPersonController' could not be found (are you missing a using directive or an assembly reference?)
    Anything from HDRP, packages or assets is broken in Visual Studio (works great in Unity, but it makes debugging impossible). Any easy fix for this kind of 'broken link' (I'd guess) ?
     
  2. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
  3. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    120
  4. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Woow, that's weird.

    Have you tried to see to create a new project to see if you have similar errors?

    If you can create a new project without any issue, then you can maybe start adding piece by piece the assets from your original project in order to find the root of the problem.

    Maybe you can try the next sequence:
    1. Create a new empty project
    2. Add the packages from the Package Manager
    3. Include all the asset store plugins and assets
    4. Import all the other 3rd party libraries and plugins
    5. Add all the art assets and other non-code resources
    6. Include the Editor scripts
    7. Finally, include the rest of your scripts
    In that way, you can find in which step the errors are triggered.

    Once you find the problematic step, then you can subdivide his content to dig even with more precision what is making your project have all the mentioned errors.


    I hope this helps!
     
  5. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    120
    Thanks for the help ! In the end I just updated Unity to the latest LTS version and it seems to have fixed it. (glad I havent had to do the whole time consuming reconstructing the project process).
     
    DiegoDePalacio likes this.
  6. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    120
    Okay so it turns out it only helped for a short amount of time... The problem came back a few hours (days maybe) later, and I have been living with it ever since (which was painful). Today I decided to try and fix it once and for all, I tried multipe things like regenerating project files (in the preference -> external tools), resetting the argument, deleting the .vs folder etc. Not only did that not help, but now when I open a script, VS Code takes a few minutes to load all the errors (35K+), and then after a few minutes it crashes.
    The thing is, the project works perfectly with Visual studio 2019, so I'm guessing the issue is not within the project but rather the file that communicates between Unity and VS Code...
    The errors made debugging a nightmare, but not being able to use it at all is a whole other level. Fishing for help again...
     
  7. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Hi @VincentAbert,

    Maybe you can try the 7-step sequence that I suggest before.

    I know that it's going for you to take some time, but if you find the issue once for all, I think it well worth it.


    Good luck with it!
     
  8. harleydk

    harleydk

    Joined:
    Jul 30, 2012
    Posts:
    41
    I had a bit of luck in regenerating the project files, maybe that works for others with the same issue.

    upload_2021-5-14_19-59-54.png
     

    Attached Files:

  9. RevenantDevs

    RevenantDevs

    Joined:
    Mar 3, 2019
    Posts:
    2
    Thank you!!
     
    harleydk likes this.
  10. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
    You saved my life ! Thank you very much
     
    rc82 and harleydk like this.
  11. ZaherHa

    ZaherHa

    Joined:
    Jul 28, 2018
    Posts:
    5
    Worked for me thanks
     
    harleydk likes this.
  12. browne11

    browne11

    Joined:
    Apr 30, 2015
    Posts:
    128
    God bless that regenerate button, instant fix!

    The 7 step procedure attached should be your last resource as deleting your library can take a while. I usually you plan this out ahead of time to clean my project up.
     
  13. rc82

    rc82

    Joined:
    Jan 28, 2020
    Posts:
    22
    YES!!! THANK YOU!
     
  14. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    576
    If you have any issues with visual studio first thing you do is nuke the `.vs` folder in project root.
    I know you tried it, but its a reminder for everyone else.
     
  15. Notreal76

    Notreal76

    Joined:
    Jul 28, 2020
    Posts:
    1
    Thank you so much. That fixed it for me!
     
  16. krokots

    krokots

    Joined:
    Oct 3, 2017
    Posts:
    6
    Also had this problem, also that was an instant fix, thank you man.
     
  17. Okiski

    Okiski

    Joined:
    Nov 9, 2017
    Posts:
    2
    Thank You, that worked me aswell.
     
  18. jaimelugo

    jaimelugo

    Joined:
    Nov 8, 2019
    Posts:
    27
    Hero!!
     
  19. wykj-luke

    wykj-luke

    Joined:
    Feb 11, 2020
    Posts:
    6
    Thanks!!!!