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
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.
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.
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! :)
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>
© 2022 - 2024 — McMap. All rights reserved.