The designer could not be shown for this file because none of the classes within it can be designed

后端 未结 11 2512
一个人的身影
一个人的身影 2020-12-09 14:53

We have the following shared component:

public class OurServiceBase : System.ServiceProcess.ServiceBase

This class has functionality we wan

相关标签:
11条回答
  • 2020-12-09 15:01

    Here's another possible solution:

    Under the project properties under build, my platform target was set to x64. I updated this to "Any CPU", rebuilt my project and the designers opened fine.

    This explains it better: Visual studio designer in x64 doesn't work

    0 讨论(0)
  • 2020-12-09 15:02

    Your best bet would be to start with a version of OurServiceBase with no functionality and see if you can design MyService. If so, then slowly add back functionality until it breaks.

    Since it looks like Visual Studio is having a problem serializing one of the members of OurServiceBase.

    0 讨论(0)
  • 2020-12-09 15:03
     form1.designer.cs // was showing this
               this.Components = new System.ComponentModel.Container();
               this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
       `enter code here`        this.ClientSize = new System.Drawing.Size(800, 450);
                this.Text = "form1";
      //  I had to add this to the code to get it to work
       this.Name = "form1";
       this.ResumeLayout(false);
       this.PerformLayout();
    
    0 讨论(0)
  • 2020-12-09 15:04

    You may also run into this problem if your control/service is inheriting from a generic class. The designer doesn't get along well with abstract classes in the hierarchy, since it has to instantiate them.

    0 讨论(0)
  • 2020-12-09 15:10

    Further to Ausibanez's answer above.

    My app was in X64 but my problem was I had recently added a COM reference to WIA (Windows Image Acquisition) which was the issue.

    But oddly...

    1. It worked for some time before it decided to no longer work, and
    2. WIA was not being called on the particular inherited form or its base.

    But, once the reference to WIA was removed, all was OK again.

    So, check your COM references!

    0 讨论(0)
  • 2020-12-09 15:15

    I just closed all the UI pages and cleaned my solution and build it again it started working.

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