Home > Mobile >  Inherited control not showing in designerview while x86
Inherited control not showing in designerview while x86

Time:09-17

I'm creating a windows app in Visual Studio 2019. I use a COM reference (IBM PCOMM v 13, 32 bit) that only works when i set project target to x86.

When I change target from Any CPU or x64 to x86, the COM-reference works great. However, all the controls that I have created by inheriting, disappear from the designerview. The form is basically empty. My own controls are stored in separate .cs-files that are included in the project.

When I change target back to Any CPU or x64, my controls reappear, but the COM reference won't work (due to not x86).

This is the .cs code of one of the simpler controls I use in my form:

using System;
using System.Drawing;
using System.Windows.Forms;

namespace Stackoverflow
{
    public class LabelTitle : Label
    {
        public LabelTitle()
        {
            ForeColor = Color.FromArgb(0, 95, 165);
            Font = new Font("Segoe UI", 11, FontStyle.Bold);
        }
    }
}

It's worth noting that the standard controls work in x86. However, I would prefer to use my own custom controls.

How can I continue to use my own controls while building in x86?

CodePudding user response:

I finally found a solution, though I don't understand why this solves the problem.

After trying the solutions provided in the comments and reproducing the errors in new projects by adding and changing line by line, I found that it was the target framework that caused the error.

The first project (that threw errors) used the template Windows Forms App with .NET 5.0 framework. However, if I instead use template Windows Forms App (.NET Framework) with framework .NET 4.7.2 all my inherited controls work perfectly fine with x86. So far, all my COM-references and my controls work great with the .NET 4.7.2 framework.

  • Related