Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Visual Studio not recognizing Unity Namespaces

Discussion in 'Editor & General Support' started by lifetree, Jan 23, 2019.

  1. lifetree

    lifetree

    Joined:
    Mar 28, 2014
    Posts:
    47
    Hi,

    I have this issue where after upgrading to Unity Plus and Unity Teams Advanced and Collaborate, my visual studio isn't working. When I open a script, all of the unity namespaces have red squiggly lines underneath (and all related functions and variable also have red lines underneath). Technically, everything still works, so unity is parsing it correctly, but VS won't recognize it. Makes it very difficult to write code. What would be the cause of this? I did change my unity user as well in case that might be an issue.

    I just downloaded a new copy of Unity with VS thinking that maybe something wasn't lining up, but nothing. Now, I didn't delete Unity or VS before downloading, thinking it would just overwrite both of them, but maybe it didn't overwrite VS. Should I download again after deleting both Unity and VS?

    Thanks for any help you can provide
     
  2. lifetree

    lifetree

    Joined:
    Mar 28, 2014
    Posts:
    47
    Update: I deleted Unity and VS, and redownloaded both from the Unity Download Assistant, to ensure that I have compatible versions. It is still doing it. Has anyone else had an issue like this?
     
  3. lifetree

    lifetree

    Joined:
    Mar 28, 2014
    Posts:
    47
    Update 2 (giving more information so you know what I have or haven't tried): Deleted .sln and .csproj files, and the entire Library folder to allow Unity to rebuild. Still getting the same issue. I am running out of ideas here. I really can't have this delay in my workflow. If anyone has any ideas, I would be eternally grateful.
     
  4. lucernagame

    lucernagame

    Joined:
    Nov 5, 2018
    Posts:
    19
  5. lifetree

    lifetree

    Joined:
    Mar 28, 2014
    Posts:
    47
    Thanks for your reply. I have all my scripts in the Assets/Scripts folder, so that second thread probably doesn't apply. Might just be a bug that has yet to be squashed. I have resorted to using a different script editor. I much prefer VS, but you gotta what you gotta do I guess.
     
  6. lifetree

    lifetree

    Joined:
    Mar 28, 2014
    Posts:
    47
    I found this error in VS, I'm guessing this is what is going wrong, but not sure how to fix. I manually obfuscated the path for security reasons and because it isn't relevant: Error MSB4019: The imported project "/Users/**********/obj/Assembly-CSharp.csproj.*.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. (MSB4019) (Assembly-CSharp).
     
  7. lifetree

    lifetree

    Joined:
    Mar 28, 2014
    Posts:
    47
    Ok, so I was able to fix this issue. Following is the solution in case it helps anyone:

    I realized that my associate named the new Unity project (because of Unity Teams Advanced and Collaboration) with a colon in it. So when VS went to make the solution file, it would name it based off of the folder name, but since it didn't like the colon, it would use a forward slash instead (big problem). I tried renaming it, but it would just keep recreating a solution using the forward slash because of the bad project name. So I renamed the project name to no longer have a colon, I deleted all .sln and .csproj files again, and I also deleted .vs directory (holds temp data and thought it might be interfering. It is automatically regenerated by VS, so no reason to not delete this). If you don't know how to delete .vs, go to your Terminal (Mac instructions), navigate to the project folder, and type "rm -R .vs". Simple as that.

    I had to find my project again as Unity didn't recognize the new name. Opened it up, opened a script in VS, and it worked!

    TL;DR, The name of the project folder had an incompatible character causing the .sln file to fail. Hope this helps someone!