How to resolve VS2010 Windows Form Designer issue (base class could not be loaded)

前端 未结 8 2122
天命终不由人
天命终不由人 2021-01-01 11:16

I have recently been getting an error in the Windows Forms designer of VS2010SP1 when using inherited UserControls.

The error is

The designer

相关标签:
8条回答
  • 2021-01-01 11:52

    I've been having this issue a lot recently and found an easy and fast workaround and decided to share it (works for me on VS 2012).

    When you have a Form like this:

    public partial class MyForm : MyBaseForm
    

    and the designer fails to design MyBaseForm saying the base class 'System.object' cannot be designed, all I have to do is to remove : MyBaseForm and revert (Backspace > Ctrl + Z). The designer will come to its senses then.

    public partial class MyForm : MyBaseForm // The designer has trouble with this
    public partial class MyForm              // Force an error
    public partial class MyForm : MyBaseForm // Revert back, the designer should now work again
    

    All that's left to do now, is to wait for Microsoft to fix that annoying bug.

    0 讨论(0)
  • 2021-01-01 11:55

    I had the same issue. I had a Form object/base object I was inheriting from, and all of a sudden I see this message for all Forms that were inheriting from the Base.

    I tried to backtrack and figure out what changed recently and remembered I set my project Platform Target from Any CPU to x64. I changed it back to Any CPU and the problem got resolved, and then setting it back again to x64 still kept the problem fixed.

    This was on VS 2013, by the way.

    0 讨论(0)
  • 2021-01-01 11:57

    I solved this issue renaming all my forms and user controls and than renaming them back again...

    For Example:

    My user control...

    Right click on..,

    Renaming...

    And then do the same whit the original name all works now...

    0 讨论(0)
  • 2021-01-01 12:01

    I had this bug with VS2015, tried clean/rebuild steps, build in release didn't work.

    I put the base control in another project and the designer complained that there wasn't a constructor for it. I had a constructor with 2 arguments, but no empty one. I added an empty constructor and the designer worked. I then moved the base control back in it's original location with the derived controls, and the designer bug came back.

    I gave up and just put the base control in a "VsBug" project, seems to be happy...

    0 讨论(0)
  • 2021-01-01 12:04
    1. Clean Project (not sure if this is necessary)
    2. Set build to Release
    3. Rebuild Project

    The forms designer will not rebuild the forms that you manually edited if you build the project in Debug mode apparently.

    0 讨论(0)
  • 2021-01-01 12:04

    I also have found that when you are trying to design a form that may have referenced libraries that are already in use, then it fails to design.

    I often run several Visual Studio instances. If I leave an instance of VS running a program in debug mode, and that program shares a library with the instance of Visual Studio in which I am trying to design, then I run into this problem. It also can be as simple as the DLL that the designer references is in use.

    Once you close the program that is locking those library files then the designed returns to normal.

    0 讨论(0)
提交回复
热议问题