Visual Studio - Reload closes all tabs

If add a script in Unity, then switch to Visual Studio, Visual Studio requests that I reload.

Reloading closes all tabs.

How to resolve?

Are you on the most recent version of Visual Studio? 2019 or 2022?

Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.2.2

Haven‘t been using VS for years but I do remember it having odd glitches. It may help to close VS, delete all .sln and .csproj files from the unity project root folder and then try again.

Thanks, but didn’t help!

What do you recommend using instead?

I use Rider. Not free but if you consider paying it‘s definitely the better choice over VS for Unity dev thanks to native support and the built-in decompiler.

Update to the mostly recently released version. I believe these issues have been fixed.

2 Likes

@CodeSmile : Cool to see Copilot is available for Rider. I’ll consider it if VS keeps bugging out!

@spiney199 : Thanks. Just updated and appears to have fixed it.

Had the same issue with visual studio 2022 version 17.2.2
Can confirm that updating to 17.2.3 will fix it

Still there in 17.3.4.
Reloading causes some tabs to close and sometimes tabs get duplicated.

1 Like

This is a problem again as of 17.14.1 for me

Same. Dang it why did I have to update…

1 Like

I have tried the advice about deleting the .csproj,.sln and .vs files/folder and it makes no difference.

Since the update, Unity’s rebuilding of the files knocks the currently viewed scripts off the page. It is clearly possible to solve this because it has been working just fine on and off for many versions.

It is a massive pain in the backside as I cannot work from scripts in different parts of my solution without having to hunt them all down whenever I create or delete a script.

I’ve emailed the VS Tools for Unity team about this but a Bug Report like this might make the process faster: Developer Community

1 Like

Hello, we are tracking this issue here (with a workaround):

Developer Community

3 Likes

I have the same problem VS 2022 Community Version 17.14.2 and Unity 6 0.41f1

From the link @sailorbrnk provided:

As a temporary workaround, you can create the following Editor script (so to be located in an Editor folder). You need to use the VS Editor package v2.0.23+.

This will switch to the new SDK-Style project format.

using UnityEditor;

public class CustomProjectGenerator : AssetPostprocessor
{
    // This method is called when the project generation is triggered.
    public static string OnSelectingCSProjectStyle()
    {
        // "SDK" (Used by VS Code)
        // "Legacy" (Used by Visual Studio, but newer versions are able to handle SDK-Style projects as well)
        return "SDK"; 
    }
}  

Then restart Unity, or force a project-file re-generation.

1 Like

The latest update from VS2022 Community solved this. Thanks for the swift turnaround!

1 Like