Problem: The Windows Forms designer does not work for an inherited user control when the base class is implementing an interface from another assembly.
Platform: VS 2010 SP1, .NET 4.0 Framework
Error:
The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: MyControl --- The base class 'MyBaseControlLib.MyBaseControl' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)
I have a solution with 3 class library projects:
MyInterfaceLib:
namespace MyInterfaceLib
{
public interface IMyInterface
{
void Foo();
}
}
MyBaseControlLib:
namespace MyBaseControlLib
{
using System.Windows.Forms;
using MyInterfaceLib;
public partial class MyBaseControl : UserControl, IMyInterface
{
public MyBaseControl()
{
InitializeComponent();
}
public void Foo()
{
}
}
}
MyDerivedLib:
namespace MyDerivedControlLib
{
using MyBaseControlLib;
public partial class MyControl : MyBaseControl
{
public MyControl()
{
InitializeComponent();
}
}
}
Although the designer works for MyBaseControl it does not work for MyControl. If MyBaseControl does not implement IMyInterface, the designer also works for MyControl.
Any ideas?
Thanks, Robert
Form. This base class provides the functionality you need to design Windows Forms applications.
The primary way a control is added to a form is through the Visual Studio Designer, but you can also manage the controls on a form at run time through code.
WinForms won't be deprecated until Win32 is ... which could be quite sometime! WPF on the other hand has few direct dependencies on Win32 so could potentially form the basis of a "fresh start" UI layer on a future version of windows.
We had the same issue. We used a workarround by creating a MyControlDesign class that is inherited by MyControl class.
public partial class MyControl : MyControlDesign {
public MyControl()
{
InitializeComponent();
}
}
public partial class MyControlDesign : MyBaseControl
{
public MyControlDesign ():base()
{
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With