Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug Visual Studio 2022 fails to open solution to selected script from Unity and keeps opening new window

Discussion in 'Editor & General Support' started by epratt, Jul 7, 2022.

  1. epratt


    Oct 15, 2019
    Using Unity 2020.3.28f1 and Visual Studio 2022 Professional. Made sure Visual Studio 2022 didn't have any updates.

    Just so we're clear, there is no problem with Unity and Visual Studio 2022 Professional communicating. I can debug, use intellisense, etc. Everything works fine in that sense (Yes I know there are posts about this already, but bear with me). I have the typical problem where when I double click on a .cs file in Unity it opens visual studio solution file, but it doesn't open to the file that was selected in Unity. It only opens the solution to a blank page. And what's even better is if I already have the solution open when I select a file in Unity, it will open up the solution... again... in another window... Does the whole loading bar thing, making the connection between Unity and Visual Studio and everything.

    [This is the gist][1] of what people say to do when things aren't behaving properly when opening a script in Unity.

    I've been using 2019 Professional and just installed 2022 Professional. I've looked at tons of posts both on stackoverflow and here and have followed all steps for anything related to my problem and still haven't found a solution. I feel like this is a new case, thus the new question.

    **What I've done (in order):**

    - I made sure I was on the most up-to-date Visual Studio Editor package in Unity (2.0.15 at the moment)
    - I updated preferences in Unity by going to Edit > Preferences > External Tools and selected Visual Studio Professional 2022 (17.2.3)
    - Ticked Embedded packages, Local packages, and Player projects
    - Code Optimization On Startup is set to Debug on the General tab
    - Uninstalled VS 2019
    - Restarted my computer
    - cleared all unity and visual studio files out of appdata, localappdata, and what was listed in the LocalLow folder in appdata for Unity
    - opened a .sln file from windows explorer and told windows to use VS 2022 to open files with that extension
    - Closed out of Visual Studio
    - Removed all csharp files from my unity project along with the .vs folder and .sln file
    - Deleted all files/folders in my Unity project except for Assets, Packages, and Project Settings
    - Opened Unity and let it do its thing
    - Went to preferences in Unity and clicked on "Regenerate project files"

    Windows knows to open .sln files using Visual Studio 2022, Unity opens the .sln file when I double click on a .cs file, a link is made between Unity and Visual Studio so I can debug and do other things, and yet, it will never open the actual file that was selected. And it will always open a new window every time.

    If I create a completely new project, add a script, and try to open it, I get the same thing.

    I was able to duplicate it on this TLS release: 2021.3.4f1. I can't upgrade to a newer version of Unity, anyway, because of some pipeline related reasons I'd rather not get into.

    I work over a vpn on an extremely secure network so I don't know if that has something to do with the disconnect, but thought I'd throw that piece of information out there just in case.

    I'm not sure if this would be a bug with Unity or Visual Studio or if its even a bug at all, though it makes sense to me that it would be a unity bug. If the only fix is to upgrade to the newest version of Unity then I'll just accept that I'm screwed and just go back to VS 2019 or just accept that I need to use the solution explorer in VS to open up scripts rather than navigate to them in Unity. I just really like some of the new features that 2022 brings, so that will be a bummer to go without those.

    Any help is appreciated. Thanks!

  2. CodeSmile


    Apr 10, 2014
    Any help? Really ANY?

    Okay then … start using Rider. :cool:

    Anyway, check if the issue persists in newer Unity versions ie 2020.3.latest or 2022.1. If not an upgrade might fix it.
    Do you get the same issue of VS opening new tabs when doubleclicking a .cs file in Explorer multiple times? Text wasn‘t clear about that.

    Can you create a local user (offline) account on this machine just to see if anything account or von specific interferes?
    In case your machine is remotely administrated contact your admin. I cannot count the numerous non-obvious issues we had due to an earlier employer’s networking and security restrictions.
  3. leegod


    May 5, 2010
    have you solved? same happens. vs2022 opens new window for each script.
    theflamingshadow101 likes this.
  4. valentunkulakov6


    Jun 29, 2018
    i was faced with issue that Visual Studio 2022 can't load solution. I just go to Project and the above of "Rescan Unreal Engine Blueprint Assets" has to be "Reload Project" button or smth like that. After that my scripts was loaded succesfuly to VS 2022. Hope it will helps