Search Unity

Why does each C# script open in a new separate instance of Visual Studio?

Discussion in 'Code Editors & IDEs' started by TokyoDan, Feb 7, 2017.

  1. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    I'm working on a project and it is OK. I open various C# scripts and each one opens in a new tab in the single running instance of Visual Studio Community 2015. To make a backup of the project, I copied and pasted it and then renamed it. I then opened that copied project in Unity, but when I open various C# scripts and each one opens in a completely new instance of VS2015.

    I've been doing this way of making backups then opening the copies for years and this has never happened before.

    What is going on?

    NOTE: Disregard this. It was fixed by deleting all the .csproj and .sin files.
     
    Last edited: Feb 7, 2017
    AaronC and Evershifting like this.
  2. smacbride

    smacbride

    Joined:
    Jan 10, 2015
    Posts:
    50
    Under the main project directory, you need to delete the {projectname}.csproj, {projectname}.Editor.csproj, and the {projectname}.sln files.
     
  3. nextage575

    nextage575

    Joined:
    Nov 4, 2019
    Posts:
    20
    I had this problem as well, I believe it was related to upgrading a project to a new version of unity. I resolved it by deleting the .csproj files and the .sln file for the project. Unity just recreated them immediately, and the files correctly opened in the same instance of VS.
     
  4. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    This is happening to me now. deleting those files doesn't fix it. I just upgraded to 2020.1.6f from 2019.4.3f
     
    Last edited: Sep 18, 2020
  5. wannadie

    wannadie

    Joined:
    Jun 19, 2014
    Posts:
    1
    The same here. I just removed Visual Studio Editor package from Package Manager, and the problem looks like fixed now
     
  6. kharerishit

    kharerishit

    Joined:
    Mar 18, 2020
    Posts:
    7
    THANK YOU OH MY GOODNESS. These multiple instances were so frustrating because if I didn't notice, every time I tried to save it would tell me "you've edited this file externally" and I would have to resolve like 5 windows.

    Do you know what the difference is between the "Visual Studio Editor" and the "Visual Studio Code Editor" ? Just out of curiosity...
     
    xXQuabbeXx and tomar8880 like this.
  7. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    VS code is a completely different IDE. It’s free and very customisable, but I don’t like it myself...

    I’ve logged a bug to unity about this multiple instances issue but they’re struggling to reproduce it. Please log a bug with a new empty project that reproduces the bug as that may help them.
     
  8. giggioz

    giggioz

    Joined:
    May 11, 2017
    Posts:
    52
    Wow, that worked for me, thank you so much.
    A lot of answers on internet just mention to delete the project files (which did not work for me).
     
  9. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    please log a bug with unity. They seemed to think it was something specific to me and my project but it's obviously not. the more people that log it the better chance they'll resolve it.
     
  10. andrin2020

    andrin2020

    Joined:
    Mar 9, 2014
    Posts:
    29
    THANK YOU!!! Nothing else worked. You have saved me countless headaches and precious minutes.
     
  11. zoranigic

    zoranigic

    Joined:
    Oct 4, 2019
    Posts:
    16
    I have to remove both "Visual Studio Code Editor" and "Visual Studio Editor" packages, restart unity and THANKS GOOD!
     
  12. tomcarnevale

    tomcarnevale

    Joined:
    Dec 26, 2019
    Posts:
    6
    Removing VS editor did not work UNTIL i restarted the project.

    Unity 2020.20b7

    Issue seems to be with the editor package, although ive always had issues using VSCode (not VS) with unity on macOS, specifically with the IDE knowing what unityengine classes are and being able to quick fix classes that havent been imported
     
  13. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    I heard back from QA at unity. Apparently it’s to do with the automation permissions for unity hub and VS being disabled in the latest MacOS. Open your security settings find automation in the list and see if you can turn them back on.

    in my case i cannot because the applications are not in MacOS security automation settings to allow me to turn them back on. :/

    I’m not sure how to add them and haven’t got a reply about it yet.
     
  14. deex

    deex

    Joined:
    Feb 21, 2020
    Posts:
    3
    fixed it for me too! 3 years later! :D
     
    Last edited: Oct 28, 2020
  15. jmenossi

    jmenossi

    Joined:
    Mar 12, 2015
    Posts:
    5
    In my case (Windows 10, VS Community 2019 and Unity 2020.1.9), nothing of the above worked, but I noticed the problem didn't reproduce when I changed project's path.
    Don't know what was wrong with the folder/subfolder name. No special characters or too many subfolder levels.
    A new project in the same folder than the original didn't work, but creating or moving it to a different folder was fine.
     
  16. ChiuGa

    ChiuGa

    Joined:
    Aug 24, 2017
    Posts:
    6
    Thank you! fixed it. you save my time!
     
  17. syamilsynz

    syamilsynz

    Joined:
    Dec 22, 2013
    Posts:
    31
    In my case using unity 2020, this happen after I update Visual Studio. Therefore, you need to update visual studio editor at unity also.

    Unity > Window -> Package Manager > select unity Packages: In Project > Visual Studio Editor > Click Button Update
     
  18. MarkA2049

    MarkA2049

    Joined:
    Jan 2, 2019
    Posts:
    2
    I have the same problem, but I notice it only happens when I create a new script, and only the first time I open that script. If I close the new instance of VS then reopen the script, it will go to the VS I already had open. Win 10, Unity 2020.2

    Won't removing the VS editor package also remove intellisense and VS actually knowing what the Unity classes are?
     
    Davidjsap likes this.
  19. Davidjsap

    Davidjsap

    Joined:
    Aug 17, 2017
    Posts:
    11
    I too am nervous about removing the editor package, worried that will make things worse and not better. Can anyone confirm what removing the package does?
     
  20. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    You don’t need to worry. I removed it and it seemed ok. You can always add it back in.

    Fyi this bug seems fixed now, I’m on the latest VS on macOS and the latest unity and packages.
     
  21. gegabal

    gegabal

    Joined:
    Sep 3, 2014
    Posts:
    2
    Thank you !~
     
  22. ivanngoc

    ivanngoc

    Joined:
    Nov 9, 2018
    Posts:
    9
  23. BerndRos

    BerndRos

    Joined:
    Oct 15, 2019
    Posts:
    2
    My solution is to swap in Edit/Preferences/External Tools to "Visual Studio Community 2022"
     
  24. Nixokol

    Nixokol

    Joined:
    Jan 27, 2019
    Posts:
    1
    What worked for me is the following:
    • Open your Unity project.
    • In your tabs go to Window / Package Manager.
    • When it opens, click on Visual Studio Editor.
    • If it is out of date, you will see an "Update to" button appear next to the "Remove" button in the bottom-right corner of the Package Manager window.
    • Click "Update to".
    • When the update is finished, try opening your scripts again. It should now open all scripts in the same instance of Visual Studio. If it still opens different instances, try restarting your Unity.
    Hope that helps! It worked for me!;)
     
  25. Feral_Pug

    Feral_Pug

    Joined:
    Sep 29, 2019
    Posts:
    49
    I tried everything in this thread, switching back to VS 2019 from 2022 works. Maybe using the latest VS doesn't work so well...
     
  26. unity_R15D8-qo-lxJ3A

    unity_R15D8-qo-lxJ3A

    Joined:
    Feb 29, 2020
    Posts:
    1
    Might be too late, but I've just encountered this problem on Windows 11, VS 2019 and managed to solve it. What works for me is to delete all the .csproj files, the .sln file AND the hidden .vs folder.

    Edited: never mind, after some time it starts acting up again...
     
    Last edited: May 13, 2023
  27. kanoder

    kanoder

    Joined:
    May 24, 2020
    Posts:
    4
    I just changed machine, with an updated Unity (2021.3.14f1) and VS (Version 16.11.26) and still having this issue .. it's really annoying
     
  28. JoyceBosmans

    JoyceBosmans

    Joined:
    Nov 17, 2023
    Posts:
    1
    I've tried the above solutions but nothing seems to work for me. Also, unable to remove Visual Studio Editor in the package manager. Using Unity version 2022.3.14f1. Any ideas?
     
  29. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Please make sure you are using the latest VS Editor Package (2.0.22) and the latest VS 2022 17.8.3.
    Regarding the package manager, perhaps you need to use the "unlock" button to be able to properly use a newer version.

    Thanks!
     
  30. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    542
    It usually works fine for me, but sometimes VS will open a dialog and ask you to adjust the file endings of the current file, if you try to open a new script, while this dialog is open, it will open a whole new instance. So make sure that you close this dialog before you try to open any new scripts.
     
  31. zeinhatduong

    zeinhatduong

    Joined:
    Sep 18, 2021
    Posts:
    16
    Y'all, updating the Visual Studio Editor and Visual Studio Code Editor Package to the latest version fixes it all, no need to delete any files (i don't even know where and what the csproj and sln files are)