Summary answer so far: Forms and controls only open in the designer if csproj.user file exists.
The problem story:
I have 2 controls that both inherit from a base control. However one is missing the control icon in the solution explorer
The good control source starts with
public partial class UniTabMaterialsControl : UnitabBaseControl
{
public UniTabMaterialsControl()
{
InitializeComponent();
}
The bad control source starts with
public partial class UniTabMaterialsControl : UnitabBaseControl
{
public UniTabMaterialsControl()
{
InitializeComponent();
}
The base control class is
public class UnitabBaseControl : UserControl
{
}
I have tried closing and re-opening Visual Studio
[Update]
I added a new user control and set it to also inherit from UnitabBaseControl , strangely the behaviour corrected.
I was then able to delete the new control and maintain correct behaviour
Git shows that there has been a change in UnitabBaseControl.cs but I do not see what changed other than the colour of the UserControl text
I then made a fresh clone of the whole solution. This time the incorrect behaviour showed on all the controls that inherited from UnitabBaseControl
[Update]
Now I suffer the same issue with forms
using System.Windows.Forms;
namespace SBD.VivSnap.UI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
and
using System.Windows.Forms;
namespace SBD.VivSnap.UI
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
}
}
[Update]
I neglected to mention that my project was a library project referred to by the start up project.
I deleted and then re-added the library project reference in the start up project. Then all the forms and controls appeared correctly.
I could not find any changes in Git to indicate why the solution now worked.
Since then I have noticed the problem in my main project
[Update]
It turns out that my project is in .sdk format even though it is framework 4.7.2 I am thinking this may have something to do with it.
I am using Framework 4.7.2 with an sdk project
Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"
I checked out the code onto a different computer running VS2019 16.1.4 and it builds ok.
I am using 16.11.4
[Update] Now I have updated to 16.11.5 and cloned again but still have the problem.
[Update] The project file is
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<OutputType>WinExe</OutputType>
<AssemblyName>Main</AssemblyName>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<PropertyGroup>
<StartupObject>SBD.VivSnap.Main.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Data.SqlClient">
<Version>2.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore">
<Version>3.1.12</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer">
<Version>3.1.12</Version>
</PackageReference>
<PackageReference Include="NuGet.Build.Tasks.Pack" Version="5.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SnapInUI\SBD.VivSnap.UI.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>
The csproj.user file is in my answer.