Perhaps the problem is in one of the features of the studio, I don’t know if it’s a bug or a feature, but it ruined some of my nerves in my time.
Entry conditions:
In VS, a project is opened on a link from the list of the most recently opened projects from the main page of the studio or by clicking on the file someProject.sln .
Case One:
User Response:
From the menu open-> project or by clicking on the file otherProject.sln in the folder open any other project.
Studio Reaction:
The project opens in a new studio copy, everything is fine, the behavior when compiling and running is expected.
Case two:
User Response:
Through the menu open-> file or by clicking on the file in the folder open someFile.cs .
Studio Reaction:
The file opens in a new tab of the editor, regardless of whether the file belongs to an already open project or not. And this is sometimes bad.
For example, you can open a file whose name matches one of the files of an open project or open a file from a copy of a project. At the same time, this file, alien to the project, is neither visually different, and the presence or absence of errors in it does not affect the compilation process, since he does not participate in it, nor on the result of the compilation, for the same reason. A simple way to calculate the twin is to close all tabs altogether and open the ones you need through Обозреватель решений .
In general, the studio does not really know how to work with single files, I would say, it does not know how at all, only with projects and all the accompanying attributes. Therefore, after the opening of the project, I strongly recommend using only the Обозревателем решений to open source files.