I have a generic UserControl abstract class, SensorControl , which I want all sensor control panels to inherit from.
Problem
When trying to create an EthernetSensorControl (one of my inherited UserControl forms from Visual Studio, the following error appears in the form designer:
A designer cannot be shown for this file, because none of the classes inside it can be designed. The designer checked the following classes in the file: DeviceSensorControl --- Failed to load the base class "Engine.Sensors.SensorControl". Make sure that the assembly contains links and that all projects are built.
SensorControl class:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace Engine.Sensors { public abstract class SensorControl<SensorType> : UserControl where SensorType : class { protected SensorType _sensor; public SensorControl(SensorType sensor) { _sensor = sensor; } } }
An example of a legacy EthernetSensorControl class:
namespace Engine.Sensors { public partial class EthernetSensorControl : SensorControl<EthernetSensor> { public EthernetSensorControl(EthernetSensor sensor) : base(sensor) { } } }
And the call stack:
in System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument (manager IDesignerSerializationManager) in System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoadManer.DesignerMenery.DesignerMenery.DesignerService.DesignerServer in System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad (host IDesignerLoaderHost)
Everything compiles and I see that the panel is displayed, but I cannot create it. I think the problem might be related to partial classes. Any ideas?
inheritance c # templates partial-classes windows-forms-designer
Petrus theron
source share