Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
controls and forms missing icon and view designer option in vs2019 running SDK project with framework 4.7.2

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 missing icon

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

base class colour changed

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

form not showing correct icon

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

problem in 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.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

It turns out that the csproj.user files were not in source control. When I copied myproject.csproj.user to the project folder and opened in VS then the forms appeared correctly.

The file contents is

<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup />
  <ItemGroup>
    <Compile Update="Form1.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Update="Form2.cs">
      <SubType>Form</SubType>
    </Compile>
  </ItemGroup>
</Project>

This leaves me with the dilemma of whether or not to check the csproj.user into source control. I had thought this was not necessary before but it seems it is. Plus the name "user" would imply it is user specific.

over 4 years ago · Santiago Trujillo Report

0

The form's compile type is probably not set properly as "form" in the .csproj file. Open the .csproj file and make sure you have this line of code wherever "form1.cs" is mentioned:

<Compile Include="form1.cs">
      <SubType>Form</SubType>
    </Compile>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!