Search Unity

Error with Unity and Visual Studio Bridge (VS project not updating when new scripts added)

Discussion in 'Editor & General Support' started by Korno, Jan 9, 2018.

  1. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    Recently, I keep getting the following error in the Unity console:

    When this occurs I lose code completion in all of the Unity API and if I add new scrips via Unity, the C# solution does not see them.

    Weirdly, Unity does compile the new scripts though...

    Any ideas on how to fix this? It has stopped me from doing any scripting as I cant see the new scripts in the solution and no code completion is annoying.
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Is it perhaps an old Visual Studio Tools for Unity (VSTU) version that is stored in the project?

    I had a similar issue when I upgraded a project, where VSTU was imported to that project, to a newer Unity version. It seems this caused an issue, because never Unity versions ship VSTU with Unity itself and the plugin doesn't need to be installed in the project. In my case, I just removed the VSTU directory from the project Asset folder.

    If that's not the case for you, you can try to reinstall VSTU.
     
    yuvzohar and JulioKasper like this.
  3. alior

    alior

    Joined:
    Sep 6, 2014
    Posts:
    25
    Hi guys! I found out that in my case the issue was related to presence of Post Processing stack v2 in the project. After deleting it, everything seems to be fine. Maybe they are using assembly definition as I see that there is additional com.unity.postprocessing... csproj file (See screenshot)
    Hope it helps.
    upload_2018-2-3_7-7-9.png
     
    Fuzzba11 likes this.
  4. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Hey, I've been encountering this issue too! Absolutely nothing from reimporting to removing/regenerating solution files helps, it looks like Unity invariably trips on the PostProcessing assembly no matter what. I'm using 2017.3.0f1.
     
    MilC likes this.
  5. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Same here with PostProcessing stack v2. 2017.3.0p2

    Is there a workaround ? VS stopped show me auto-completion it's annoying.
     
  6. Nail_Sharipov

    Nail_Sharipov

    Joined:
    Jul 25, 2016
    Posts:
    2
    AttilaZold, JackofTraes and nattd like this.
  7. Hoorza

    Hoorza

    Joined:
    May 8, 2016
    Posts:
    45

    Did just that and the problem still is here. Doesn't seem to affect the build or anything it is just there. Waiting for the fix.
     
  8. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
  9. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    167
    Oh, S***. Oh-S***-oh-S***-oh-S***-ohshit! Guys, it's really sucks, we need a fix like yesterday! I removed all project-related files and Unity won't generate them again! Please, please, please make a fix - can't work! :(
     
    Alex_May likes this.
  10. jbeucus

    jbeucus

    Joined:
    Apr 30, 2018
    Posts:
    2
    I see the error in the console of brand new projects. The error appears before anything is even added to the project! Help!
     
    Andros_Spica likes this.
  11. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    I really need help with this like right now guys - I'm starting a paid contract today and my fresh install of 2017.3.1f1 does not generate solution files
     
  12. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Remove every single asmdef file from PostProcessing, it will continue to work fine without them and the problem would be solved.
     
    mtanu and Alex_May like this.
  13. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    I am not using the postprocessing stack and it's not part of some of the projects that are doing this... I am tryign a full uninstall of all Unity and VS installations and reinstalling.
     
  14. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    OK, fully uninstalling and reinstalling Unity and VS2017 has fixed the issue for me.
     
  15. BoTreats

    BoTreats

    Joined:
    Mar 7, 2014
    Posts:
    3
    I reinstalled Unity and VS as well and it worked, but then the problem surfaced again. I've been able to keep it at bay by keeping my solution file in version control (which I don't like doing), and then when this issue comes up again, I revert the change made to the solution and everything continues to work for another few hours of development.

    It's not ideal at all, but it's better than a full reinstall every time the issue pops up.

    Also, something that is a bit faster than reinstalling everything, but has the same effect of giving you a good solution file again, is to just repair the VS Unity Tools, which you can grab at this link: https://marketplace.visualstudio.com/items?itemName=SebastienLebreton.VisualStudio2015ToolsforUnity
     
    Alex_May likes this.
  16. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    Nice - before the nuclear option I did try to repair the install using the visual studio 2017 installation manager but it didn't appear to fix the issue. Might have been a good idea to try to install them externally as you suggest.
     
  17. Pnvanol

    Pnvanol

    Joined:
    Jan 11, 2016
    Posts:
    123
    same problem here ... and now there is no monodevelop...
     
  18. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Same problem using a project I upgraded to Unity 2018.1.0f2. Fortunately my code still works, but I get no intellisense in Visual Studio, and everytime I open a script from the project window, it opens another instance if Visual Studio......again and again. Very annoying.

    The error in console says:
    "ArgumentException: Value does not fall within the expected range.
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit)"
     
    TakuanDaikon and uwustudio like this.
  19. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Ok, I found a quick fix, at least it's working so far, but I don't recommend it unless you backup your project, and even then do so at your own risk.

    Again, *Don't do this unless you back-up your project* (and you're willing to risk any potential problems).

    I simply opened my project with Unity 2017 (a version I had previously). Then, in Unity 2017 I double-click (opened up) a script in that version. It generated the necessary ".sln" solution files for my project. Then, I again opened up the same project in Unity 2018, and Unity once again recognized my code solution (no bridge compilation errors anymore), and the necessary .sln files were once again in my project folder.

    It worked great for me so far :)
     
  20. flyingaudio

    flyingaudio

    Joined:
    Dec 3, 2010
    Posts:
    98
    This error showed up after I installed 2018.1.1f1 (I was on 2017.4). I uninstalled VS2017, and then reinstalled it using the above link, and included the Unity add-on. During the install, I saw syntax tree being added. Started up Unity with no errors this time, and code completion is working again.
     
    AttilaZold likes this.
  21. el_lobo_66

    el_lobo_66

    Joined:
    Sep 25, 2014
    Posts:
    1
  22. Dartimos

    Dartimos

    Joined:
    May 25, 2017
    Posts:
    1
    Glad to see this is happening to others and its not something just on my end. I've reinstalled multiple times and it works for the first build or two then goes haywire. I'm almost sure it has something to do with the interactions between Unity and the compiler. I had an old version of MonoDev still and this whole thing started when it did the same thing with MonoDev.
     
  23. noahx

    noahx

    Joined:
    Nov 22, 2010
    Posts:
    77
    I was experiencing the same error after updating Unity from 2017.3.0f3(no error) to 2018.1.2f1(got the error as soon as I opened my project). So, I closed Unity and I updated Visual Studio (the free version) and I opened Unity again and the problem was gone.
     
  24. Zarkow

    Zarkow

    Joined:
    Jul 27, 2015
    Posts:
    92
    I got the error, but here is how I fixed it:

    'Edit' -> 'Preference...' (opens dialog 'Unity Preference')
    Select page 'External Tools'
    Insetting 'External Script Editor' Unity had selected 'Visual Studio 2015' -- so I selected 'Visual Studio 2017 (Professional)' and then the error disappeared.
     
  25. guayeah

    guayeah

    Joined:
    Jun 9, 2017
    Posts:
    6
    This worked for me, thank you so much!!!
     
  26. Kubiz91

    Kubiz91

    Joined:
    Jun 25, 2015
    Posts:
    1
    This also worked for me, turns out that all I had to do was to update "Visual Studio tools for Unity". Thank you :D
     
  27. Dustin_Anglin

    Dustin_Anglin

    Joined:
    Feb 18, 2016
    Posts:
    3
    Had almost exactly the same issue going from 2017.3.0f to 2018.1.4f. Upgraded Visual Studio and that cleared everything up. My heart definitely got its workout today...:p *phew*
     
  28. megan_l_fox

    megan_l_fox

    Joined:
    Jul 10, 2010
    Posts:
    35
    Yep, this also worked for me. I'm on 2017.4 LTS version and was having this issue, hadn't even moved to 2018. But I had just added PostProcessing v2.

    Anyways, yay I can work again!

    EDIT: Also, it apparently HAS to be Visual Studio Community 2017 now. When I tried setting it back to Community 2015, the errors came back.
     
    Last edited: Jun 18, 2018
  29. VBenincasa

    VBenincasa

    Joined:
    Feb 13, 2014
    Posts:
    12
    Also getting this issue even in a completely fresh project.
    As soon as the project is created, the .sln already fails to be created with that error message.

    Updating Visual Studio 2017 solved the issue.
     
    Last edited: Jun 15, 2018
    uwustudio likes this.
  30. mbrindic

    mbrindic

    Joined:
    Mar 13, 2014
    Posts:
    16
    Ok, so whole day later, I manage to fix this by reinstalling both Unity and Visual Studio. Than, I run Unity installer, and I checked Visual Studio to be installed from Unity installer. I think that's the way to make it work, so try to not install Unity and Visual studio separately.
     
  31. RaviRK

    RaviRK

    Joined:
    Aug 6, 2017
    Posts:
    5
    Updating Visual Studio 2017 solved the issue
     
    JulioKasper, uwustudio and alinev like this.
  32. gokujosemanuel29

    gokujosemanuel29

    Joined:
    Jun 25, 2018
    Posts:
    5

    I already have 2017 but the error still appears
     
  33. acaton

    acaton

    Joined:
    May 27, 2013
    Posts:
    28
    I just had to upgrade my Visual Studio 2017 and it works fine now. Good luck.
     
  34. eurecat_viz_group

    eurecat_viz_group

    Joined:
    Nov 7, 2017
    Posts:
    1
    Another success story here. I upgraded Visual Studio 2017 as you suggested and it fixed it. Thank you guys!
     
  35. Shootingdutchtman

    Shootingdutchtman

    Joined:
    Aug 28, 2017
    Posts:
    2
    When updating to 2018.2.1f1 had the same problem, updating Microsoft visual studio 2017 by running the installer again I had the option to update. After the update I used modify to check if Unity was enabled and saved the settings.

    After that it worked again.
     
  36. UnityGISTech

    UnityGISTech

    Joined:
    May 6, 2015
    Posts:
    193
    [ problem solved for me ]

    1- Upgrade Visual Studio 2015 tools for unity to the last version Version v3.7.0.1

    Last updated 10/05/2018 à 01:27:4

    2- Restart Unity and VS
    3- open visual studio and go to tools-->NuGet Package Manger --->Package Manager Console

    Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform

    thats work .

    you can t tracked visual studio erros on .log file to know what was te problem.
     
  37. ALKubo

    ALKubo

    Joined:
    Mar 3, 2017
    Posts:
    3
    This worked for me:

    1- Edit/Preferences/External Tools
    2- Selected a diferent script editor, or "Open file by extension"
    3 - Wait for Unity save changes
    4 - Selected my version of Visual Studio again
    5 - Wait for Unity save changes
    6 - double click a c# script file

    and the sln file was recreated after that
     
    Jason-H, Binbag42 and Velo222 like this.
  38. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    Uninstall and re-install VS2017 is the best solution, it worked for me, no more errors
     
  39. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    *See ALKubo's solution above it is similar* I think it has to do with Visual Studio being dumb and not being able to find your project solution files...…. so to trick Unity into finding your solution files you can do something like ALKubo mentioned above, and it worked for me too without having to update Visual Studio to a new version all of the time.

    In the Unity Editor, you can go to Edit->Preferences. Click on the "External Tools" tab. Then in "External Script Editor" dropdown option select "Browse" and browse your Windows folders for Notepad (I had to find the Notepad.exe on Windows first then I could navigate to it). Once you have Notepad selected as your External Script Editor, open one of your scripts (it should open with Notepad). Close it, and now switch back the External Script Editor to using your version of Visual Studio you are using. Unity should now find your .sln solution file again.

    I hope that might help, and I hope the Visual Studio team can keep this fixed, it really shouldn't keep breaking with every version of Unity or Visual Studio being released......it is VERY annoying. Thank you.
     
    NSdesignGames likes this.
  40. lucidcoder

    lucidcoder

    Joined:
    Mar 23, 2010
    Posts:
    138
    Just throwing in my 2 cents that I was able to fix this too.

    What fixed it for me was similar to Velo222's suggestion above, but the issue was I migrated from Unity 5.6, and I was using Visual Studio 2015 at the time. I needed to go to Edit->Preferences->External Tools and then change the script editor from VS 2015 to VS 2017, because it seems to have inherited preferences from 5.6.

    This has solved the issue for me.
     
  41. DerDicke

    DerDicke

    Joined:
    Jun 30, 2015
    Posts:
    292
    huh!
    Fixed it by updating VS 2015 and reinstalling VSTU (Visual Studio Tools for Unity).
    Could not migrate to VS2017 because I've no Visual Assist license for it.
     
  42. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    301
    I am using mac, and VS 2017 for mac, and having this problem, any idea ?
     
  43. UnityGISTech

    UnityGISTech

    Joined:
    May 6, 2015
    Posts:
    193
    hi all, visual studio woks very slow for big projects it takes alot of time to load all scriptes so i changed to JetBrains Rider 2018.2.3 it works well for me. here link to the video
     
  44. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,476
    This occurs too at 2020.2.1f1, VS 2019
     
  45. TekHK

    TekHK

    Joined:
    Jul 30, 2014
    Posts:
    37
    @leegood - did you fix this? - I have the same updating an old project.
     
  46. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,476
    I got following solution from unity QA team and I solved by this.

    ----
    This issue seems to be caused by an outdated .dll being leftover from an older version in the project. Please try deleting UnityVS.VersionSpecific.dll from your Assets\Images\UnityVS\Editor folder in your Project directory (Please make a backup just in case something goes wrong). That should prevent the SyntaxTree error from being thrown again.
    ----
     
  47. TekHK

    TekHK

    Joined:
    Jul 30, 2014
    Posts:
    37
    Nice - thanks - I got it working, but I will do a double check for this file just in case it reoccurs.
     
  48. Babster

    Babster

    Joined:
    Jun 7, 2020
    Posts:
    20
    Had this issue after changed VS code to VS community and the solution is to restart Unity and Studio and it works! Thanks to everyone!
     
  49. TidusMMM

    TidusMMM

    Joined:
    Jun 19, 2017
    Posts:
    1
    I solved this issue by going to the project folder and deleting the hidden .vs folder.