VS 2008 keeps removing and re-adding <SubType>ASPXCodeBehind</SubType>

I've got a VS 2008 C# Web project and whenever I make some changes to the files in it (not even to the project file itself) VS will remove some lines like this from the csproj file:

<SubType>ASPXCodeBehind</SubType>

So something like this:

<Compile Include="Default.aspx.cs">
  <DependentUpon>Default.aspx</DependentUpon>
  <SubType>ASPXCodeBehind</SubType>
</Compile>

will become

<Compile Include="Default.aspx.cs">
  <DependentUpon>Default.aspx</DependentUpon>
</Compile>

BUT the next time I work on this project it will add those lines back! It keeps going back and forth like this, resulting in a lot of meaningless "changes" in our source control system. This never used to happen with VS 2005 and it doesn't seem to be happening for other developers who work on the same project file, only for me.

Does anyone know why this is happening and how I can stop it from doing this?


For me, the difference depends on whether or not the web project is open in Visual Studio.

I find if I commit the project file to version control with the project open in Visual Studio the SubType elements are present. Closing the solution/project then removes the SubType elements from the project file. Now I always ensure my commits are performed with the project closed in VS to avoid unnecessary changes to the project file.


Working on VS2010 and solved this issue by deleting solutionFileName.sln.DotSettings.user file and solutionFileName.suo. That helped me, give it a try.


Splitting the content of your file into multiple files - one file per class may help.

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=283434

Up-to-date link:

https://developercommunity.visualstudio.com/content/problem/389773/vs-2017-keeps-removing-and-re-adding-aspxcodebehin.html