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

后端 未结 11 2513
一个人的身影
一个人的身影 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:17

    You can also try doing this:

    • Close all the UI design pages
    • Clean Solution
    • Build Solution
    • Open the desired UI design pages

    This might or might not help but it certainly resolved the same issue in my project.

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

    I had a solution with 2 projects (one referencing the other) and I had just set one to target .Net 4.5.2 and the other was targetting 4.5.

    Tip: view the warning messages in the Error List:

    There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:....dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

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

    Just in case some one like me have to work on a old project base on Visual Studio 2008 and face the same problem.

    It's probably because the project path contain some exotic chars like C#

    Example, my path look like that :

    C:\projects\C#\projectname...

    When it's renamed to

    C:\projects\CSharp\projectname...

    Visual Studio is now able to recognize parent class and then open the form with the inherited form.

    0 讨论(0)
  • 2020-12-09 15:19
    1. Open "Designer.cs" file
    2. Cut all code and save file
    3. Paste all code and save file
    4. Re-open form / Restart Project / Restart Visual studio (whichever works)

    This will do the trick

    0 讨论(0)
  • 2020-12-09 15:27
    1. Go to Project>>Properties>>Linker>>System, in the field "SubSystem" you choose "Windows (/SUBSYSTEM:WINDOWS)", click Apply.

    2. Go to Project>>Properties>>Linker>>Advanced, in the field "entry point", input value "Main" and Apply, finally click OK.

    3. Go to file code of form you created(ex: MyForm.cpp) and input code bellow to this file:

    using namespace System;

    using namespace System::Windows::Forms;

    [STAThreadAttribute]

    void Main(array<String^>^ args)

    {

    Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Project1::MyForm form; Application::Run(%form);

    }

    1. Save and rebuild.
    0 讨论(0)
提交回复
热议问题