Form and designer files not linking in Solution Explorer

后端 未结 5 529
礼貌的吻别
礼貌的吻别 2020-12-15 18:21

I can\'t seem to get the form and the designer files to link in my project. They look like this in the Solution Explorer.

相关标签:
5条回答
  • 2020-12-15 18:38

    I've seen the same problem in Visual Studio 2008. Usually after compiling or closing and re-opening the solution the problem would fix itself. In Visual Studio 2012 I know that I have problems if I try to Add > Existing Item and choose all three files. Typically you only want to add the top level form.cs and VS will automatically include the .designer.cs and .resx files.

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

    Check the project (.csproj) file.

    Inside the ItemGroup node, see if the .designer file is associated with the code-behind file. The XML should look something like this:

    <Compile Include="FormPrompt.cs">
        <SubType>Form</SubType>
    </Compile>
    <Compile Include="FormPrompt.Designer.cs">
        <DependentUpon>FormPrompt.cs</DependentUpon>
    </Compile>
    
    0 讨论(0)
  • 2020-12-15 18:41

    include the .resx file into the project and in the properties of this file set Custom Tool as ResXFileCodeGenerator

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

    In VS2017 (c#) to solve it, in my case:

    1. exclude all file
    2. go to folder
    3. rename file (all 3 file .cs.Designer.cs .resx)
    4. refresh solution
    5. add to project back
    0 讨论(0)
  • 2020-12-15 18:56

    Check the project (.csproj)

    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator> Check this
      <SubType>Designer</SubType>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen> And Check this
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    
    0 讨论(0)
提交回复
热议问题