Visual Studio 2022 fails to open solution to selected script from Unity and keeps opening new windows
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 the file that was selected in Unity. It only opens the project 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 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 the most recent LTS Release of unity today (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!
Your answer
![](https://koobas.hobune.stream/wayback/20220613061633im_/https://answers.unity.com/themes/thub/images/avi.jpg)