Visual Studio resx editor creating duplicate designer file
Asked Answered
P

4

13

On my current project whenever I add, update or delete a resource the tool creates a copy of the designer file which screws things up. I don't see this behavior with my other projects, and as far as I can tell I'm implementing resources the same way. Can anyone shed some light on this behavior? Thanks

Petulant answered 13/10, 2014 at 23:41 Comment(0)
M
18

Visual studio 2017

The reference to the duplicated designer file is in the csproj file.

  • Close the solution
  • Edit your project .csproj
  • Locate the LastGenOutput tag
  • Remove the '1' on the designer file

You can now reload the solution. If you want to regenerate the designer file:

  • Delete it
  • Edit the resx file and save The new designer file is recreated.
Metempirics answered 14/5, 2018 at 11:52 Comment(0)
D
4

Unfortunately I have no idea what was causing this for me but after wasting a fair bit of time I found a work around which seems to of worked without issues for me.

I simply deleted the designer file and re-built my project. This automatically re-creates the designer file and everything continued to work as normal.

The only noticeable difference is the designer file now has a 1 on the end of it.

E.g. String.resx -> Strings1.Designer.cs

I have been making changes on and off to this file in the past with no issues. If anyone could explain what got it into this corrupt state, please share with us.

Debenture answered 9/3, 2015 at 9:36 Comment(1)
That's pretty much the same approach I use Robert. Obviously an annoying issue for us if we break the solution with resx updates then have to delete the designer file and rerun the custom tool. Haven't been working on this aspect of the project for awhile but I think it was not happening on every update and there was no discernible pattern. I'm wondering if it's a VS edition issue (I'm on 2013 Pro)Petulant
B
3

Open up the project file (using a different editor, such as notepad, notepad++, etc.) and look for something like the following:

<Compile Include="YourResourceFilename1.Designer.cs">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>YourResourceFilename.resx</DependentUpon>
</Compile>

Change it to <Compile Include="YourResourceFilename.Designer.cs">... then save the file and then build the project. You might need to delete the file YourResourceFilename1.Designer.cs as well. Also, might be worth searching for any further appearance of YourResourceFilename1 in that file.
Good luck! :)

Bedim answered 20/4, 2017 at 16:34 Comment(0)
O
0

The problem was in .csproj file, in .csproj file the entry with lastgenerated output file for my resource file was resource2.designer.cs.. i chaned it to resource.designer.cs and its working..

<EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources2.Designer.cs</LastGenOutput>
    </EmbeddedResource>
Ovipositor answered 13/4, 2023 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.