다음을 통해 공유


Settings1.Designer.cs Bug: Multiple settings files

I ran into this bug today which was unfortunately closed as can't repro. I was renaming some AppSettings variable names (right click on a Project's  Properties and go to the Settings tabs) and deleting some other settings, when I did a Search/Replace for the entire solution and somehow wound up with a duplicate Settings.Designer.cs file named Settings1.Designer.cs. This was effectively a clone of Settings.Designer.cs which meant:

  • IntelliSense would report that any AppSettings variables were declared multiple times
  • The project wouldn't compile because the variables were already declared

The fix was to

  • From the Error menu, double click the Settings1.Designer.cs file to open it. Right click on the file and select Open Containing Folder and backup the the offending file(s) first (just in case).
  • After backing up, delete the Settings1.Designer.cs file
  • Switch back to VS and ensure Show All Files is selected in the Solution Explorer
  • Expand Settings.settings in the Solution Explorer and manually delete Settings1.Designer.cs (and if prompted say yes to removal from source control)
  • Select Build...Clean Project... (or Solution as appropriate)

You should be good to go, if you get an error about a missing file, you may need to manually open your csproj or sln file in Notepad and ensure that the MSBuild script doesn't contain a link to Settings1.Designer.cs.

Comments

  • Anonymous
    January 11, 2009
    Hi, i am using Visual Studio 2008 Pro since few months and have SP1 too (on XP SP2 laptop). Today all of a sudden, when adding/editing the Settings it's throwing the following errors: 'Settings is ambiguous between declaration in Modules '<project>.My.MySettingsProperty' and '<project>.My.MySettingsProperty' (same) I noticed that the studio created a duplicate of Settings.Designer.vb file as Settings1.Designer.vb I then deleted the duplicate file from the 'My Project' folder and deleted the same in the Solution Explorer under Settings.settings But once i do the above, the new setting added will not show up in the IntelliSense on typing My.Settings. And when i try to edit/add setting, it creates the duplicate Settings1 again and throws 'Settings is ambiguous between ....' errors I also noticed that the timestamp of 'Settings.Designer.vb' doesn't change while Settings1.Designer.vb is always updated whenever settings are edited. Both files have write permissions. This is very annoying and frustrating. Does anyone know a working permanent fix to this problem? Thanks, -srinivas yelamanchili

  • Anonymous
    June 01, 2010
    Found a solution. I had the same problem with a resource file, every time i had a modification to this file, vs created a "resourcename"1.Designer.cs I tried the solution below, but nothing changed. the fix is to go in you project csproj or vbproj : looki for the weird designer, Settings1.Designer.vb in your case and replace it by Settings.Designer.vb in my case it was : <EmbeddedResource Include="ResourcesResTexts.resx">      <Generator>ResXFileCodeGenerator</Generator>      <LastGenOutput>ResTexts1.Designer.cs</LastGenOutput>    </EmbeddedResource> I changed it for <EmbeddedResource Include="ResourcesResTexts.resx">      <Generator>ResXFileCodeGenerator</Generator>      <LastGenOutput>ResTexts.Designer.cs</LastGenOutput>    </EmbeddedResource> Now everything is fine Hope this will help you