Visual Studio 2010 Designer Error on Run

后端 未结 17 684
借酒劲吻你
借酒劲吻你 2021-02-03 21:42

I am using using VS2010 and if I have a form open in designer mode and run my application the designer tab will no longer show the form designer but instead an error will be di

相关标签:
17条回答
  • 2021-02-03 22:43

    Close the form. Clean the solution. Rebuild the solution. Reopen the form. Worked for me when nothing else would.

    0 讨论(0)
  • 2021-02-03 22:43

    I'm able to avoid restarting VS by doing the following

    1. Add a new user control
    2. Drag and drop some of your custom user controls on to it (If it gives you an error, build the solution again).
    3. Reopen your control.

    In my case, I have a winforms project with several custom controls that are used by other custom controls. Whenever I open some of those custom controls, I get a the "The base class ..." error. Adding a new custom control, building the project and then adding some custom controls from my project to the new custom control allowed me to open the custom controls that were giving me the "The base class ..." error.

    UPDATE: I think I found the problem. My controls were not 'added' properly to the csproj file. In the csproj file, the files for partial classes of UI controls/components need the 'DependentUpon' attribute.

    E.x.: before:

    <Compile Include="Windows\Forms\DataGridView.cs">
        <SubType>Component</SubType>
    </Compile>
    <Compile Include="Windows\Forms\DataGridView.Designer.cs" />
    

    after:

    <Compile Include="Windows\Forms\DataGridView.cs">
        <SubType>Component</SubType>
    </Compile>
    <Compile Include="Windows\Forms\DataGridView.Designer.cs">
        <DependentUpon>DataGridView.cs</DependentUpon>
    </Compile>
    
    0 讨论(0)
  • 2021-02-03 22:44

    I usually close the visual form, rebuild the solution, right-click then select "view designer" in the form code.

    Very, very annoying. I am thinking of dropping back to VS2008.

    0 讨论(0)
  • 2021-02-03 22:44

    I had a situation where a custom user control appeared to be creating the error (not sure why) so I removed references to the user control from the form and the error went away.

    0 讨论(0)
  • 2021-02-03 22:44

    Old post, but for those whom may find this...

    Just ran in to this error and for me it was relatively simple fix.

    Found that it may have something to do with the names of your classes, and renaming the problematic class to a higher order. That is the alphabetical order it appears in the assembly (Where A is higher than Z).

    MSDN Article

    Good luck.

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